+ 2
I Am having a problem making this python program to run the syntax error is coming from line 3. I am using pydroid 3 to run it
here is the code password = 2 float (user_input = input("enter your password")) if (user_input== password) print("password accepted") else print("access denied")
7 Réponses
+ 15
I just modified the code. It had many errors.
Now you can refer this :
password = 2
user_input = float(input("enter your password")) #proper placement of float
if (user_input== password): #colon was missing
print("password accepted")
else: #colon was missing
print("access denied")
#also use proper indentation for if-else.
+ 9
But I didn't got any error when I ran the code.
See this :
https://code.sololearn.com/cmYE2vcAJsjT/?ref=app
+ 5
Technically, password is an integer and not a float. So you should check if user_input equals int(input('...')) and not float(input('...')). This doesn't really make any difference because 2 (int) is equal to 2.0 (float) in python, but it's always a good idea to avoid unnecessary bugs/inconsistencies in your code...
+ 4
Azino Oreva You're probably entering a string? The problem is that non-numerical strings like 'abc' can't be converted to integers or floats so when you use the int() or float() function on the string, there will be an error.
If this doesn't solve your problem, please show your code
+ 3
thanks a lot
+ 2
thanks a lot guys it's running properly
0
Although I corrected the indentation problem it ran but whatever you type creates an error