Whats wrong with this code | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

Whats wrong with this code

x = input("Enter a number: ") if x > 10 print("Number is greater than 10.")

23rd Jan 2024, 12:47 PM
Python Vietnam
Python Vietnam - avatar
9 Antworten
+ 4
You should convert the input into int and the if statement are missing ( : )
23rd Jan 2024, 1:49 PM
Mohamed Beder Oumar
Mohamed Beder Oumar - avatar
+ 3
X=int(input("Enter a number:")) if x>10: Print("Number is greater than 10.")
24th Jan 2024, 2:42 AM
Amirhassan gorji
Amirhassan gorji - avatar
+ 2
OP, do you use ChatGPT? Ask the chat bot what’s wrong, and it can highlight the issues for you, telling you why it’s wrong. It helps if you’ve been staring at code too long and can’t see the errors anymore hahhah
25th Jan 2024, 3:39 AM
Brandi Hubbard
Brandi Hubbard - avatar
+ 1
Tips Try the code in the playground, and check the data type of variable x. This command tells you the data type (it also covered in the course). print(type(x))
23rd Jan 2024, 1:48 PM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
https://sololearn.com/compiler-playground/cZsJ3Fr3BeSV/?ref=app Use this as a reference. It's a debug of the code written above
23rd Jan 2024, 5:24 PM
Ekojoe Covenant Lemom
Ekojoe Covenant Lemom - avatar
+ 1
It's a correct : x=int(input("Enter a number: ")) if x>10: Print(x) print("Number is greater than 10")
24th Jan 2024, 4:38 PM
Prajakta Kamble
Prajakta Kamble - avatar
0
Discuss section is NOT A QUIZ. Do you need help with your code?
23rd Jan 2024, 12:52 PM
Lisa
Lisa - avatar
0
I didnt know
23rd Jan 2024, 12:52 PM
Python Vietnam
Python Vietnam - avatar
0
x=int(input()) if x>10: print("Number,You choosed, is greater than 10.") else: print("Number,You choosed, is lesser than 10.")
31st Jan 2024, 4:25 PM
hour 11
hour 11 - avatar