+ 3
smallest number
def smallest(): num_1=float(input("Enter your first number:")) num_2=float(input("Enter your second number:")) num_3=float(input("Enter your third number:")) if (num_1<=num_2) and (num_1<=num_3): smallest=num_1 elif (num_2<=num_3) and (num_2<=num_1): smallest=num_2 else: smallest=num_3 print ("The smallest number is:",smallest) smallest() this code do not run .its show problem in 14 line. how can slove it ..what problem of my code? after run the program show that (NameError: name 'num_1' is not defined
6 odpowiedzi
+ 2
I got an error stating that on line 14, there is a syntax error. This is because after the part in quotations in your print function, you're supposed to have a plus (+) sign seperating the variable and the string. Also, when printing a variable, you can only print it if it is a string, so it might help to surround the variable name in the print function in a str() function.
Hope this helped!
+ 2
This works:
https://code.sololearn.com/caWj84cnHPQe
+ 1
Link your code by hitting share and copy link. Followed, by pasting link into a post. OR use + Insert button on the apps post popup. Without seeing it as coded, it looks like an indentation issue.
+ 1
num_1 is not defined.. please anbody run the program of your computer than give me a pic
0
there is some indentation pblm...
just fix that...
like c, java python doesnt use {} for blocks of code...
it used indented blocks...
its importent to keep track of that...
fix that
0
indentation is ok ..this is no problem...
after run the program show that (NameError: name 'num_1' is not defined