Suppose, you want to confirmed the user from one list to another list we can confirm using while loop. we will confirmed the user is verified or not.
(1) unconfirmed_users = ["alice","brian","cadace"]
confirmed_users =[]
# verify each user until # there are no more #unconfirmed user
# move each verified user into the list of confirmed users
(2)
while unconfirmed_users:
current_users = unconfirmed_users.pop()
print("verify user:"+current_users)
confirmed_users.append
(current_users)
# Dislay the #confirmed_users
(3) print("The following users have been confirmed : ")
(4)for confirmed_user in
confirmed_users:
print(confirmed_user)
Output:
verify user: cadace
verify user: brian
verify user: alice
The following users have been confirmed:
cadace
brian
alice
Explanation:
At (1) the list is unconfirmed_users list.
Then there are empty list of confirmed users.
We have to verify the user then transfer in confirmed_users.
At (2) the while loop is applied ,when the users are unconfirmed_users.
Remove the item from unconfirmed_users, store in current_users variable. The last item will come first because it has pop. Then,this verified users display.
At (3) the statement has display about the confirmed_users.
At (4) for loop has
used for display the confirmed_user.
😀😀😀✒✒