+ 3
What’s wrong with this?
#Search for either a builder, plumber or electrician search = input('Search') if search == builder print ('Shane, builder, 51 with flexible times') else: print ('No result') if search == electrician print ('Dave, electrician, 32 with speedy service') else: print ('No result') if search == plumber print ('Alan, plumber, 47 with lots of experience') else: print ('No result')
6 Respostas
+ 4
instead of using multiples if...else
consider using if...elif...else
+ 3
after the if conditions you should put a colon (:)
+ 2
Also, builder, electrician etc. need to be in quotation marks
+ 1
thank you!
+ 1
you didn't necessarily do this wrong, but if I were you I'd convert search to lowercase so the case of the user's input doesn't prevent them from finding a match. you could add a line after search is declared :
search = search.lower()
this way, an input of BUILDER still matches the user to Shane
- 1
you did not give colon(:) after each of the if statement