What is wrong in this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 13

What is wrong in this code?

a=int(input('enter the number') if a%2==0 and a>100: print(a,'is an even number and is also greater than 100')

6th Oct 2021, 3:00 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
50 Answers
+ 6
Fixed the parenthesis and the indentation. https://code.sololearn.com/cVZcnKoP7zFr/?ref=app
6th Oct 2021, 3:19 PM
Simon Sauter
Simon Sauter - avatar
+ 18
The indentation. And a missing closing parenthesis in line 1.
6th Oct 2021, 3:09 PM
Simon Sauter
Simon Sauter - avatar
+ 5
Indentation is a way to structure code (other languages use parentheses or curly braces to do that). When you indent a line you tell python that it is subordinate to another one. Examples are loops and if-elif-else structures. You have to tell python which lines should be executed multiple times (loops) or under particular conditions (if-elif-else). When you unindent a line you tell python that it is not subordinate.
6th Oct 2021, 3:48 PM
Simon Sauter
Simon Sauter - avatar
+ 3
Look at your first line. Bracket missing. The exactly code will be a= int(input ('enter the number'))
7th Oct 2021, 3:56 AM
Tousif HR
+ 3
Simon Sauter Additional contents are always helpful
8th Oct 2021, 4:03 AM
Demiz 🇬🇭🇬🇭🇱🇷🇱🇷
Demiz 🇬🇭🇬🇭🇱🇷🇱🇷 - avatar
+ 2
Welcome to the club ,bro😂
7th Oct 2021, 11:57 AM
Ario
Ario - avatar
+ 2
error handling is also very important, try/except should help incase of ValueError
7th Oct 2021, 6:41 PM
Demiz 🇬🇭🇬🇭🇱🇷🇱🇷
Demiz 🇬🇭🇬🇭🇱🇷🇱🇷 - avatar
+ 1
It is still showing error Simon
6th Oct 2021, 3:14 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
+ 1
What's the error message?
6th Oct 2021, 3:16 PM
Simon Sauter
Simon Sauter - avatar
+ 1
File "file0.py", line 2 if a%2==0 and a>100: A IndentationError: unexpected indent
6th Oct 2021, 3:20 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
+ 1
Indentation is literally the first thing I mentioned. See my code for the correct indentation.
6th Oct 2021, 3:21 PM
Simon Sauter
Simon Sauter - avatar
6th Oct 2021, 7:15 PM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Missing bracket in line 1
8th Oct 2021, 12:02 PM
🌼Faith🌼
🌼Faith🌼 - avatar
+ 1
Ghasaq Ali 1. The question has been resolved five days ago. See the comments above for details. 2. There is no loop in the code, let alone an infinite one.
11th Oct 2021, 3:24 PM
Simon Sauter
Simon Sauter - avatar
0
Thank you Simon
6th Oct 2021, 3:22 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
0
Can you teach me coding please simon
6th Oct 2021, 3:23 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
0
No. But that's what the sololearn courses are for. And when you run into specific issues you can always post another question.
6th Oct 2021, 3:25 PM
Simon Sauter
Simon Sauter - avatar
0
Which class are you in and where you live can you tell please if you don't mind
6th Oct 2021, 3:27 PM
Nilambar Karmakar
Nilambar Karmakar - avatar
0
As you can see when you click on my profile picture I am from Germany. I'm not in school anymore, I already graduated from university.
6th Oct 2021, 3:29 PM
Simon Sauter
Simon Sauter - avatar
0
From when you have started coding
6th Oct 2021, 3:34 PM
Nilambar Karmakar
Nilambar Karmakar - avatar