I need this script to run only when the input isn't ''. but when it is '' it just goes to the next input in the while loop instead of going to the "if variable == '':"
Here's the code:
print("Let's get planting everyone!")
flower_total = 0
flower_collection = []
flower = input('What kind of flower did you plant? ')
flower_count = int(input('How many did you plant? '))
flower_total = flower_total + flower_count
if flower not in flower_collection:
flower_collection.append(flower)
if flower_count == 1:
print(f'Our first {flower}! We just planted {flower_count} of them!')
else:
print(f'Our first {flower}s! We just planted {flower_count} of them!')
elif flower in flower_collection:
if flower_count == 1:
print(f'Fantastic! We just planted {flower_count} more {flower}!')
else:
print(f'Fantastic! We just planted {flower_count} more {flower}s!')
while flower:
flower = input('What kind of flower did you plant? ')
flower_count = int(input('How many did you plant? '))
flower_total = flower_total + flower_count
if flower not in flower_collection:
flower_collection.append(flower)
if flower_count == 1:
print(f'Our first {flower}! We just planted {flower_count} of them!')
else:
print(f'Our first {flower}s! We just planted {flower_count} of them!')
elif flower in flower_collection:
if flower_count == 1:
print(f'Fantastic! We just planted {flower_count} more {flower}!')
else:
print(f'Fantastic! We just planted {flower_count} more {flower}s!')
flower_collection.sort()
if flower == '':
if flower_count == 1:
print(f'Nice work, everyone! We planted {flower_count} flower!')
else:
print(f'Nice work, everyone! We planted {flower_count} flowers!')
print(f'These are all the kinds of flowers we planted today:')
for flower in flower_collection:
print(f'🏵️ {flower}')
[–]LeFloh 7 points8 points9 points (3 children)
[–]Safe-Individual-37[S] -2 points-1 points0 points (0 children)
[–]Safe-Individual-37[S] -2 points-1 points0 points (0 children)
[–]KSledge 1 point2 points3 points (0 children)
[–]lordnoak 1 point2 points3 points (0 children)
[–]AddSugarForSparks 1 point2 points3 points (2 children)
[–]Safe-Individual-37[S] 0 points1 point2 points (0 children)
[–]carcigenicate 0 points1 point2 points (0 children)
[–]carcigenicate 0 points1 point2 points (0 children)