new to python, searched google but didn't know how to phrase my question. Is there a way for me to access def describe_restaurant(self): print(f"Restaurant has served {self.number_served} customers.") specifically? At the end of my code, I'm trying to access self.number_served directly but don't know how to? Currently studying python from a book Python Crash Course and learning importing classes.
class Restaurant:
def __init__(self, restaurant_name, cuisine_type):
"""Initialise name and cuisine type attributes."""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
"""Print a statement to describe the restaurant."""
print(f"The restaraunt is called {self.restaurant_name}!")
print(f"Mainly we offer you {self.cuisine_type} foods.")
print(f"Restaurant has served {self.number_served} customers.")
def open_restaurant(self):
print("The restaraunt is now open!")
def set_number_served(self, customers):
"""Set number of customers served."""
self.number_served = customers
def increment_number_served(self, customers_served):
self.number_served += customers_served
from restaurant import Restaurant
my_foods = Restaurant('Lahe Torn', 'shokolaadikoogid')
print(my_foods.describe_restaurant())
print(my_foods.open_restaurant())
my_foods.increment_number_served(10)
print(my_foods.describe_restaurant())
#How to print only self.number_served from def describe_restaurant(self) ???