Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3 break statement
#6
Try this:
#find out an available username
# -*- coding: utf-8 -*-
import re

current_users=['vlad','kate','tania','mike','david']

def get_user():
    while True:
        name_user = raw_input('Please, enter new username: ')
        if not  re.match("^[A-Za-z0-9_-]*$", name_user):
            print("\nSorry it is a special symbols, please try again")
            continue
        elif name_user in current_users:
            print("\n Sorry,but  " + str(name_user) + "  the name is not available")
            continue
        print("your USERNAME=" + str(name_user) + "  is approved")
        current_users.append(name_user)
        print('current_users: {}'.format(current_users))
        break

if __name__ == '__main__':
    get_user()
Reply


Messages In This Thread
Python 3 break statement - by kresh - Nov-19-2017, 09:28 PM
RE: Python 3 break statement - by Larz60+ - Nov-19-2017, 10:13 PM
RE: Python 3 break statement - by sparkz_alot - Nov-21-2017, 03:26 PM
RE: Python 3 break statement - by heiner55 - Nov-21-2017, 03:36 PM
RE: Python 3 break statement - by iFunKtion - Nov-21-2017, 07:31 PM
RE: Python 3 break statement - by Larz60+ - Nov-21-2017, 09:04 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with a 'break' statement. christopher3786 3 2,501 Jun-20-2020, 10:16 AM
Last Post: pyzyx3qwerty
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,258 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619

Forum Jump:

User Panel Messages

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