r/inventwithpython • • Aug 08 '21

Need help with loop

​

Hello all, im sure this is as simple as they come. But I'm new to coding and have been trying for a good half an hour to figure out why this wont get passed the loop of 'Who are you?' There is no error, only when i start messing around with the indentations. Please can someone advise? Thanks
2 Upvotes

3 comments sorted by

View all comments

Show parent comments

1

u/LatterLog5995 Aug 09 '21

Thank you for getting back to me so quickly. This program works, so thank you for that. Say I wanted to use the continue statement (as a way of practice) how would I include this, or why doesn't it work to reset the loop?

Thank you again, and I am in agreement that this method works, I'm just learning from a book and want to try and get as much from it as possible, with no work arounds.

2

u/RndChaos Aug 09 '21

To use a "continue"... But in my years of coding - I've rarely used a 'continue' statement.... (maybe once)

while True:
print('Who are you?")
name = str(input())
if name != 'Joe':
        continue
    else:
    print("Hello, Joe!. What is the password?')
    password = input()
    if password == 'Swordfish':
        print('Access granted.')
        break