What’s wrong with this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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')

13th Oct 2018, 5:14 PM
GoatofMoominKin
GoatofMoominKin - avatar
6 Answers
+ 4
instead of using multiples if...else consider using if...elif...else
13th Oct 2018, 5:19 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 3
after the if conditions you should put a colon (:)
13th Oct 2018, 5:17 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
Also, builder, electrician etc. need to be in quotation marks
13th Oct 2018, 5:56 PM
Anna
Anna - avatar
+ 1
thank you!
13th Oct 2018, 9:16 PM
GoatofMoominKin
GoatofMoominKin - avatar
+ 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
16th Oct 2018, 12:23 AM
Jessica Wilson
Jessica Wilson - avatar
- 1
you did not give colon(:) after each of the if statement
15th Oct 2018, 5:02 AM
md zubair
md zubair - avatar