Im making a program where you can make a city and I want it so that if you type info and then the building name which is an argument in a class. All the buildings and roads are stored in 2 lists so how can I make an elif/if check if a user input is 'info'+ name argument in a class in a list?
Heres my code:
from math import pifrom random import randint as rdclass building(): radius = None height = None width = None perpendicular_height = None base_area = None end_area = None popularity = rd(1,20) def __init__(self,name,shape,window_amount): self.name = name self.shape = shape self.window_amount = window_amount try: str(self.name) except: print('\nError! Name must be a word or phrase. Not a number!\n') try: str(self.shape) except: print('\nError! Shape must not be a number.\n') try: int(self.window_amount) except: print('\nError! Amount of windows must be a number.\n') if (self.shape).lower() == 'sphere': building.radius = int(input('\nRadius: \n')) self.volume = (4/3)*(pi*building.radius)^3 elif (self.shape).lower() == 'pyramid': building.base_area = int(input('\nArea of Base: ')) building.perpendicular_height = int(input('\nPerpendicular Height: ')) self.volume = (1/3)*(building.base_area)*(building.perpendicular_height) elif (self.shape).lower() == 'cone': building.base_area = int(input('\nArea of Base: ')) building.perpendicular_height = int(input('\nPerpendicular Height: ')) self.volume = (1/3)*(building.base_area)*(building.perpendicular_height) elif (self.shape).lower() == 'cylinder': building.perpendicular_height = int(input('\nPerpendicular Height: ')) building.radius = int(input('\nRadius: \n')) self.volume = ((pi*building.radius)^2)*building.perpendicular_height elif (self.shape).lower() == 'prism': building.end_area = int(input('\nArea of End: ')) building.perpendicular_height = int(input('\nPerpendicular Height: \n')) self.volume = building.end_area * building.perpendicular_height else: print(f'Error! {self.shape} is not a valid shape.') def info(self): return f'Volume: {self.volume}\nName: {self.name}\nWindow Amount: {self.window_amount}' def enhance(self): enhancement = rd(1,20) building.popularity += enhancementclass road(): def __init__(self,name,type_,length,speed_limit): self.name = name self.type_ = type_ self.length = length self.speed_limit = speed_limit try: str(self.name) except: print('\nError! Name must be a word or phrase. Not a number!\n') try: str(self.type_) except: print('\nError! Type of road must be a word or phrase. Not a number!\n') try: int(self.length) except: print('\nError! Length must be a number.\n') try: int(self.speed_limit) except: print('\nError! Speed limit must be a number.\n') if (self.type).lower() != 'highway' or (self.type).lower() != 'expressway' or (self.type).lower() != 'express way' or (self.type).lower() != 'regular': if (self.type).lower() != 'fork': print(f'Error! {self.type_} is not a type of road. Try something like highway or fork.') else: name1 = str(input('\nName of Seperate Road 1: ')) type1 = str(input('\nType of Seperate Road 1: ')) length1 = str(input('\nLength of Seperate Road 1: ')) speed_limit1 = int(input('\nSpeed Limit of Seperate road 1: \n')) name2 = str(input('\nName of Seperate Road 2: ')) type2 = str(input('\nType of Seperate Road 2: ')) length2 = str(input('\nLength of Seperate Road 2: ')) speed_limit2 = int(input('\nSpeed Limit of Seperate road 2: \n')) self.split_road = [road(name1,type1,length1,speed_limit1),road(name2,type2,length2,speed_limit2)] def info(self): return f'Name: {self.name}\nRoad Type: {self.type_}\nLength: {self.length}\nSpeed Limit: {self.speed_limit}'buildings = []roads = []print('\nHello! Welcome to CityScape, where gamer-made civilisations thrive! To start, type building to make a building\nand road to make a road! Type info then the name of a building/road to get the\ninfo about said building/road!\n')user_input = input('>> ')if user_input == 'building': building_name = input('Building Name: ') building_shape = input('Building Shape: ') building_windows = input('Amount of Windows: ') buildings.append(building(building_name,building_shape,building_windows))elif user_input == 'road': road_name = input('Road Name: ') road_type = input('Road Type: ') road_length = input('Road Length: ') road_speedlimit = input('Speed Limit: ') roads.append(road(road_name,road_type,road_length,road_speedlimit))