Question: I'm trying to create a basic program which asks for a user to enter and then re-enter a password. If it matches, then it will print "Password created". If it doesn't, it will continue to ask the user to retry until the passwords match.

This is what I have so far; I know a loop and at least one other "if" statements is needed, but I don't know how to do it.

```
password=raw_input("please select a password")
password_again=raw_input("please re-type your password")
loop=raw_input("Password does not match. Please try again")
if password_again==password:
      print("password created")
else: raw_input(loop)

```

Help is appreciated!

Answer: 
**I think using getpass module would be a wise decision:** It will Prompt the user for a password without echoing

```
from getpass import getpass

print "Please select a password: "
passwd = getpass()

print "Please re-type your password: "
if passwd == getpass():
    print "password created"
else:
    print "Password does not match. Please try again"

```

Output:

```
Please select a password:
Password:
Please re-type your password:
Password:
Password does not match. Please try again

```
This is a great way to learn about while loops

Ask for the values

```
password=raw_input("please select a password")
password_again=raw_input("please re-type your password")

```

Loop until they match 

```
while password_again != password:
    print "They don't match please try again"
    password=raw_input("please select a password ")
    password_again=raw_input("please re-type your password ")

```