Python Forum
First program feedback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First program feedback
#1
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.

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
Reply


Messages In This Thread
First program feedback - by xyzabc12310000 - Mar-12-2018, 10:54 AM
RE: First program feedback - by tannishpage - Mar-21-2018, 09:59 AM
RE: First program feedback - by xyzabc12310000 - May-20-2018, 05:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Feedback on my first program? jibby 6 4,779 Jul-16-2018, 08:42 AM
Last Post: WolfWayfarer
  I need some feedback on this program tannishpage 3 3,189 Mar-22-2018, 05:31 AM
Last Post: tannishpage

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020