Question: 1 . Implement two lists. One list should be a list of 8 different usernames with one being admin. The other list should be a
Implement two lists. One list should be a list of different usernames with one being "admin".
The other list should be a list of different messages pleasant messages like: "Hope you are well today! etc.
Be sure to use for loops andor the appropriate control structure.
Check to see if the user equals 'admin'.
If so print an fstring, passing user directly to the print stream with a message stating: "I have a status report for you!".
If using nested for loops for example, break out of the inner loop appropriately. If the user isn't admin, then generate a random choice from the messages list and
print and fstring, passing each user directly to the print stream along with the random message.
If using nested for loops, break out of the inner loop after printing each random greeting.
Hint: You will break out of the inner loop twice if you nest You don't have to though. Iterate over the names list, and then handle your message logic in the same loop.
You need to try your best to derive a solution that you understand. There is no right or wrong here.
BE SURE TO IMPORT THE RANDOM MODULE
Hint: yourvariablehandle random.choicemessages
#YOUR CODE GOES HERE
Amend the above program and prompt the user to log in with their username.
a If the user is in the list think conditionals here continue with the above implementation # above
b If name entered is not in the list, print: Sorry username does not exist
#YOUR CODE GOES HERE
Simulating Username Uniqueness Check on a Website
a Create a list consisting of usernames, making sure to mix upper and lowercase letters, such as "kfoster or "Ddouglas
b Now, create a second list containing new usernames. Ensure that at least of the usernames in this second list match those from the first list, but vary the casing.
c Write a loop that checks each of the new usernames against the existing ones. If the username is found in the current list, display a message telling the user to pick another username. If its not found, print a message indicating that the username is available for use.
d Be mindful of case sensitivity when comparing usernames. For instance, if "Kfoster is already on the list but the new user attempts to use "kfoster the system should recognize this as a duplicate. To handle this, create a new list where all usernames from the original list are converted to lowercase.
For example:
currentusers list of current usernames
newusers list of new usernames
lowercaseusers userlower for user in currentusers
In the code above, the square brackets are used to generate a new list using list comprehension. List comprehension is a concise and efficient way to create a list by transforming another list or string. In this case, we are converting each username from currentusers into lowercase. Each item in currentusers is processed one by one iterated over and during each iteration, the username is converted to lowercase and stored in the new lowercaseusers list.
#YOUR CODE GOES HERE
Implement a list with items. Unpack it using each way outlined in the lecture materal being sure to print each time use list comprehension, the join function and others
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
