+ 3
Help
https://www.sololearn.com/Discuss/1953430/help-please number = float(input("Please enter ur number:\n")) if (number) < 50: print(f"Your number {number} < 50") if (number) > 50: print(f"Your number {number} > 50") except ValueError: print("Please enter a number") error: line 11 except ValueError: ^ SyntaxError: invalid syntax
5 Respuestas
+ 3
Here's a correct code. I've made some changes:
- If you want to use 'except', you have to use 'try' first.
- ValueError must be in brackets as an "except" 's argument.
https://code.sololearn.com/cFR86fpMdAEF/?ref=app
+ 1
Arya i missed the coverting input into float... I corrected it check again..
0
thanks buddy, is there another way to write ? for example like this?
0
If is not a loop statement hence there is no need of break (break is used to get out of loop)
three basic types of control structures:
Sequential: default mode. Sequential execution of code statements (one line after another) -- like following a recipe
Selection: used for decisions, branching -- choosing between 2 or more alternative paths. In C++, these are the types of selection statements:
if
if/else
switch
Repetition: used for looping, i.e. repeating a piece of code multiple times in a row. In C++, there are three types of loops:
while
do/while
for
Here is my modified code... Hope it will help you
https://code.sololearn.com/crVtXIi3TyJs/?ref=app
0
Sgk101 hi this wont work, because input type is always str
i couldn't find anything else