Hi,
I am new to python and i have been using it for 2 days now and have so far learnt statements and loops e.g. the while/for loops and elif statements etc. I have created a program based on a practice exercise question i found on the internet and have created my first program. Its a pointless program which just asks a user for a password and to keep asking a few times if entered wrong and grant access if correct. (Took me about an hour to write this hahhahaha but proud of myself). Anyway, i was wondering if anyone could have a look at it and see if theres any bad habits ive picked up or anyway i coulf iron the code out to make it look neater or just general feedback. Any advice would be appreciated. I have included it below.
I am new to python and i have been using it for 2 days now and have so far learnt statements and loops e.g. the while/for loops and elif statements etc. I have created a program based on a practice exercise question i found on the internet and have created my first program. Its a pointless program which just asks a user for a password and to keep asking a few times if entered wrong and grant access if correct. (Took me about an hour to write this hahhahaha but proud of myself). Anyway, i was wondering if anyone could have a look at it and see if theres any bad habits ive picked up or anyway i coulf iron the code out to make it look neater or just general feedback. Any advice would be appreciated. I have included it below.
print ('Please enter password') password = input () n = 4 while password != 'swordfish': while n > 1: print ('Incorrect password. Try again. The number of attempts remaining is ' + str(n-1)) n = n - 1 password = input() while n == 1: print ('Access Blocked') break if password == 'swordfish': print ('Access granted')Edit: indentations are not showing on this post. here is a screenshot of it https://ibb.co/n7XuHn