im new to python and im creating a program as sort of a practice exercise. It manages your plants around your house and tells you things like when to water them etc. Currently im working on the section that allows you to add a new plant. The problem im having is that im not sure how to make it so that each time i create a new plant, it has a new variable name. Here is my code:
class Plant:
def __init__(self, name, location, wateringDays):
self.name = name
self.location = location
self.wateringDays = wateringDays
def CreatePlant():
name = input("Okay, what is this plant called?\n")
location = input("Where in/around your house is this plant? (Multiple locations are fine. Located at:\n")
wateringDay = input("What days do you water this plant? Please provide each day one at a time. Type 'done' when you are finished. Water this plant on:\n")
wateringDays = []
days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
while wateringDay.lower() != "done":
if wateringDay.lower() in days:
wateringDays.append(wateringDay.lower())
wateringDay = input("And:\n")
else:
wateringDay = input("Sorry, that is not a valid day of the week. Please try again.\n")
else:
print("\nGreat! You are all done making your plant.")
Plant1 = Plant(name, location, wateringDays)
i set up a class to act as the basis for making plants. At the moment, it just puts all the values into a variable which is an object of that class. However, this obviously wont work as soon as i try to ad more than one plant, because it will just overwrite the existing one. How do i make it so that every time i add a new plant, it makes a new variable for it that doesnt already exist?
also sorry for any errors or inefficiencies in the code, i am very new to python.
i dont really know what to try, like i said im very new, i just know that i want to be able to add an infinite number of plants and have them assigned to a new variable each time.