+ 1

Where I'm making mistake in this python question

Question: https://www.sololearn.com/coach/41?ref=app Answer body : criminals = int(input()) if criminals < 5 : print ("I got this!") if criminals >= 5 : print("Help me Batman") if criminals > 10: print ("Good Luck out there!")

14th Sep 2024, 12:41 PM
Naina Kapoor
Naina Kapoor - avatar
13 Réponses
+ 4
elif criminals >= 5: Look at this line, what does it say? Is 10 great than 5? Yes, so any value greater than 5 will give you "Help me Batman". Have you looked up and/or in an if statement? Check it out 😉
15th Sep 2024, 7:54 AM
Ausgrindtube
Ausgrindtube - avatar
+ 3
You need to use a logical operator like.... >= 5 and <=10 ...and then use elif and also indentation of at least two spaces.
14th Sep 2024, 5:48 PM
Jan
Jan - avatar
+ 3
Naina Kapoor , >> please link your current code here, since we need to see what the issues are. << using `elif` alone will not help us, we also need to check / modify the conditional statements. sample: let us input 6. ... elif criminals >= 5: ... will output `Help me Batman`, but we will get the same answer when input is 14. this is because both of the values (6 and 14) are greater or equal than 5. but input 14 should give output: `Good Luck out there!` so try to improve the conditional.
14th Sep 2024, 8:15 PM
Lothar
Lothar - avatar
+ 3
Naina Kapoor , it is just one line to modify in your current code: criminals = int(input()) if criminals < 5: print("I got this!") elif criminals <= 10: # <<< print("Help me Batman") elif criminals > 10: print("Good Luck out there!")
15th Sep 2024, 11:45 AM
Lothar
Lothar - avatar
+ 3
Also Ausgrindtube Боб со Шрамом Jan Xmosity all your efforts really helped me to understand the core concept of problem solving in this question thanks to all of you dear mates 🙏💓
16th Sep 2024, 6:10 AM
Naina Kapoor
Naina Kapoor - avatar
+ 3
good luck to learning python!
16th Sep 2024, 6:20 AM
Боб со Шрамом
Боб со Шрамом - avatar
+ 2
14th Sep 2024, 1:19 PM
Ausgrindtube
Ausgrindtube - avatar
+ 2
You put some random spaces, like before the colons and between the last print and ().
14th Sep 2024, 10:07 PM
Xmosity
+ 2
Lothar this worked out , huge thanks to you 🥰
16th Sep 2024, 6:09 AM
Naina Kapoor
Naina Kapoor - avatar
+ 1
Ausgrindtube still not working
14th Sep 2024, 2:59 PM
Naina Kapoor
Naina Kapoor - avatar
+ 1
Lothar what sort of thanks logic I can use sir to range the numbers between (5-10) in statement Also thanks for your explanation above 😄
15th Sep 2024, 4:33 AM
Naina Kapoor
Naina Kapoor - avatar
+ 1
Xmosity Jan i did that as you both suggested nothing worked criminals = int(input()) if criminals < 5: print("I got this!") elif criminals >= 5: print("Help me Batman") elif criminals > 10: print("Good Luck out there!")
15th Sep 2024, 4:34 AM
Naina Kapoor
Naina Kapoor - avatar
+ 1
in first, between 5 and : there's shouldn't be spaces in second, use elif
15th Sep 2024, 11:31 PM
Боб со Шрамом
Боб со Шрамом - avatar