Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3 break statement
#1
Hi everyone. I have some problem with BREAK in my code. I don't understand why the program does not stop after adding a new username to LIST. Sorry for my question, but I'm a new in Python :) Thanks in advance

#find out an available username
# -*- coding: utf-8 -*-
print("\n===========Sing Up ====================")
print("\nPlease, enter new username:")
print("\n Username:  ")

current_users=['vlad','kate','tania','mike','david']
bad_symbols=('@','#','$','%','^','&','*','(',')','-,'_','+','=','<','>','|',']','[','{','}'',','.','/','?')
while True:
    name_user=raw_input()
    name_user=name_user.lower()
    alfabet=list(name_user)
    
    for alfa in alfabet:
        if alfa in bad_symbols:
            print("\nSorry it is a special symbols, please try again")
        else:
            if name_user in current_users:
                print("\n Sorry,but  " + str(name_user)+"  the name is not available" )
            else:
                print("your USERNAME=" +str(name_user)+"  is approved")
                current_users.append(name_user)
                print(current_users)
        break
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,471 Jun-20-2020, 10:16 AM
Last Post: pyzyx3qwerty
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 3,236 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