+ 2

Im new to coding and im not sure what I should do.

x = input() print(x) if x == 5: print("Completed") else: if x >= 6: print("Limit Exceeded") else: if x <= 4: print("Requirement Not Met")

4th Mar 2021, 9:36 PM
EXO
EXO - avatar
6 Answers
+ 4
Hello and welcome to the world of coding. If that what ŠÆрŠ¾ŃŠ»Š°Š² Š’ŠµŃ€Š½ŠøŠ³Š¾Ń€Š°(Yaroslav Vernigora) asked is true, here is a short explanation. The program asks for an input first and prints the input with the command print(x). Now the program does 3 checks. First check: if your input (x) is equal to 5 the program prints "Completed". If the number isn't 5, the program goes deeper with the first else statement. (if x >=6:) When you input is higher or equal to 6, the program prints "Limit Exceeded". Now the last statement which will come, if none of the if-conditions happened: If your input (x) is smaller or equal to 4, the program prints the text "Requirement Not Met". ************ Your Code has an error which I saw. Here is your code-text as a real Python program so you can see the output. https://code.sololearn.com/cea3RBp3k4uL/?ref=app Your input is set to a string. You need to convert it into an Integer after you requested a user input: x = int(x) Take a look at the Code.
4th Mar 2021, 9:58 PM
Julian
Julian - avatar
+ 2
Max, you should always comment your code. As your are new to coding, that's an excelent activity to put in practice. In Python we use "#" to comment. With that at the beginnig of the code, everything after will not be readed until you pull a line. #So you can make a big ststement that your code wil execute it, until you >>go ahead. About comments. Always be simple and objective: #Make it. #Receive that. #Compile this. #Show that. Doing that you will be able to understand what you were thinking and also help others to help you. You're welcome !
4th Mar 2021, 10:17 PM
ā–²TopGun ā–²
ā–²TopGun ā–² - avatar
0
Hi! do you not understand how this code works?
4th Mar 2021, 9:56 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Phyton console give us Type error. you are comparing a string with a number. bring everything to a single type
4th Mar 2021, 10:12 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Programming world is very nice if you choose and understand even a single language syntax, you'll live your life a good condition than.
4th Mar 2021, 11:23 PM
Maitama Zakari Zakari
Maitama Zakari Zakari - avatar