Q1: There is a list contianing the names of the account that has not been verfied. This list is called unconfirmed_users. We should transfer the name in the unconfirmed_users into the confirmed users. And print them out.
The output:
Verifying user:Candace
Verifying user:Brian
Verifying user:Alice
The following users have been confirmed:
Candace
Brian
Alice
The codes:
unconfirmed_users = ['alice','brian','candace']
confirmed_users = []
while unconfirmed_users:
user = unconfirmed_users.pop()
print('Verifying user:' + user.title())
confirmed_users.append(user)
print('The following users have been confirmed:')
for name in confirmed_users:
print(name.title())
Q 2: Delete a particular element all in a special list:
The original list: ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']
The new list: ['dog', 'dog', 'goldfish', 'rabbit']
The codes:
pets = ['dog','cat','dog','goldfish','cat','rabbit','cat']
print('The original list: ',end=(''))
print(pets)
while 'cat' in pets:
pets.remove('cat')
print('The new list: ',end=(''))
print(pets)
Q3: Utilize the dictionary to collect the name compared with mountain he or she loved.
What Is Your Name? sunny
Which mountian would you like to climb someday? Denali
Would you like to let another person respond?(yes/no)
yes
What Is Your Name? Emma
Which mountian would you like to climb someday? Devil's Thumb
Would you like to let another person respond?(yes/no)
no
---Poll Results---
sunnywould like to climbDenali.
Emmawould like to climbDevil's Thumb.
The codes:
responses = {}
polling_avtive = True
while polling_avtive:
message = 'what is your name? '
name = input(message.title())
message1 = 'Which mountian would you like to climb someday? '
mountain = input(message1)
responses[name] = mountain
print('Would you like to let another person respond?(yes/no)')
repeat = input()
if repeat.lower() == 'no':
polling_avtive = False
print('---Poll Results---')
for name,mountain in responses.items():
print(name + 'would like to climb' + mountain +'.')