0

Why doesn’t this work?I’m not sure why this doesn’t work, can anyone explain why please

x = input(int()) if x > 5: print("x is greater than 5") if x < 5: print("x is greater thwn 5") else: print("x = 5")

15th Oct 2021, 4:37 AM
CamM
3 RĂ©ponses
+ 4
There are 3 mistakes in your code. Here is the solution: 1. Mistake: x = input(int()) Correction: x =int(input()) 2. Mistake: if x > 5: print("x is greater than 5") Correction: if x > 5: print(str(x)+ " is greater than 5") Or if x > 5: print(f "{x} is greater then 5") 3.Mistake: if x < 5: print("x is greater than 5") Correction: elif x > 5: print(str(x)+ " is less than 5") Or elif x > 5: print(f "{x} is less than 5")
15th Oct 2021, 5:26 AM
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ - avatar
0
Your input line is wrong. The correct syntax for taking in an integer input is as follows x=int(input())
15th Oct 2021, 5:22 AM
Rishi
Rishi - avatar
0
x = int(input()) if x > 5: print(f"{x} is greater than 5") elif x < 5: print(f"{x} is less than 5") else: print(f"{x} = 5") #Or x = int(input()) if x > 5: print(str(x)+" is greater than 5") elif x < 5: print(str(x)+" is less than 5") else: print(str(x)+" = 5")
15th Oct 2021, 5:36 AM
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ - avatar