2017.5.4 if_pc_2

users = ['Eric', 'Danny','admin','Micky','Albert']

for user in users:

    if(user == 'admin'):

        print("Hello "+user+", would you like to see a status report?")

    else:

        print("Hello "+user+", thank you for logging in again.")

print("\n")

users = []

if users:

    for user in users:

        if(user == 'admin'):

            print("Hello "+user+", would you like to see a status report?")

        else:

            print("Hello "+user+", thank you for logging in again.")

else:

    print("We need some users!")

print("\n")

current_users = ['Eric', 'Danny','admin','Micky','Albert']

new_users = ['John', 'Danny','Stacie','Micky','Albert']

for new_user in new_users:

    if new_user in current_users:

        print(new_user + " has been occupied.")

    else:

        print(new_user + " can be registered.")

number_lists = list(range(1,10))

print(number_lists)

for number_list in number_lists:

    if number_list == 1:

        print(str(number_list) + "st")

    elif number_list == 2:

        print(str(number_list) + "nd")

    elif number_list == 3:

        print(str(number_list) + "rd") #这里注意输出需要将数字转换为字符,str()

    else:

        print(str(number_list) + 'th')

你可能感兴趣的:(2017.5.4 if_pc_2)