For the Gotham city challenge my Python code not working properly please assist | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

For the Gotham city challenge my Python code not working properly please assist

num = int(input("Enter the number of villans: ")) if num < 5: print ("i got this") if 5 =< num && num <= 10: print ("Help me Batman") if num > 10: print ("Good luck out there!")

4th Feb 2020, 1:58 AM
Navojit Basu
Navojit Basu - avatar
4 Answers
+ 11
if num<5: #code elif 5<=num<=10: #code else: #code I think you need to learn Python before attempting this in Python. You use "and" to represent an 'and' keyword, not '&&'. In addition, you need to use indentations appropriately. Edit: Gordon also has a point. You text needs to be EXACTLY as what is given in the question. Any alteration of characters results in an incorrect output.
4th Feb 2020, 2:02 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 7
You have to follow the required output text strictly. For example "this!" and "Luck" For posting a Code Coach challenge question/answer, we should not disclose the solution. https://www.sololearn.com/post/232552/?ref=app
4th Feb 2020, 2:02 AM
Gordon
Gordon - avatar
+ 2
Thank you for your quick response. Can you please elaborate a bit more?
4th Feb 2020, 2:02 AM
Navojit Basu
Navojit Basu - avatar
+ 1
Thank you sir for your advice. Yes I am a novice and still learning things. Thank you once again. This will help me to grow as a coder
4th Feb 2020, 2:05 AM
Navojit Basu
Navojit Basu - avatar