+ 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")

19th Dec 2018, 2:16 PM
Azino Oreva
Azino Oreva - avatar
7 Respuestas
+ 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.
19th Dec 2018, 2:33 PM
Nova
Nova - avatar
+ 9
But I didn't got any error when I ran the code. See this : https://code.sololearn.com/cmYE2vcAJsjT/?ref=app
19th Dec 2018, 2:58 PM
Nova
Nova - avatar
+ 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...
19th Dec 2018, 2:41 PM
Anna
Anna - avatar
+ 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
19th Dec 2018, 2:59 PM
Anna
Anna - avatar
+ 3
thanks a lot
19th Dec 2018, 2:49 PM
Azino Oreva
Azino Oreva - avatar
+ 2
thanks a lot guys it's running properly
19th Dec 2018, 3:06 PM
Azino Oreva
Azino Oreva - avatar
0
Although I corrected the indentation problem it ran but whatever you type creates an error
19th Dec 2018, 2:51 PM
Azino Oreva
Azino Oreva - avatar