I've tried to create a while loop to design a suburb. Device & House are classes that I made earlier in the code. For some reason i keep getting a syntax error (invalid syntax) for initialValue = len(Devices)...does anyone know what I'm doing wrong? Help would be very much appreciated, thanks.
Houses = []
Devices = []
Initial Value = 0
choice = ('Enter: e(X)it, (A)dd_house, (L)ist_house, (T)otal_usage...').uppper()
while choice [0] != 'X':
if choice[0] == 'A':
Num = input('enter house number: ')
NR = input('enter number of residents: ')
while choice2[0] != 'E' or choice != 'L':
name = input('Device name: ')
rating = input('Power rating: ')
hop = input('Hours of operation: ')
usage = int(hop)*int(rating)
new_device = Device(name, rating,hop,usage)
Device.append(new_device)
choice2 = input('add_(D)evice,(E)nd_house,(L)ist_devices...').upper()
if choice2[0] == 'E'
Houses.append(House(Num,NR,Devices[initialValue:])
initialValue = len(Devices)
if choice2 [0] == 'L':
Houses.append(House(Num,NR,Devices[initialValue:])
initialValue == len(Devices)
for house in Houses:
print(house)
if choice [0] == 'L':
for house in Houses:
print(house)
if choice [0] == 'T':
total = 0
for house in Houses:
total += house.usage
choice = input('e(X)it, (A)dd_house, (L)ist_houses, (T)otal_usage...').upper()
print('\nGOODBYE\n')
Aucun commentaire:
Enregistrer un commentaire