Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a python program that asks the user to enter the first name of the person

ID: 3703590 • Letter: W

Question

Write a python program that asks the user to enter the first name of the person they want to look up(fix it if they enter lower case) if they don't put anything and just press enter they will access a directory, then will be asked to enter the first letter of a name they're looking for. This will return a list of any names in the directory that start with the letter, as well as return them to the first question.

Also if they hit enter in the directory without any input they go back to the original name input and if they enter anything other then a single character or not a letter they get corrected and sent back to directory input(not the first option)

If the name isn’t found tell the user (use .get for this). Otherwise print a sentence like “X’s favorite color is purple and his favorite number 5"

After printing out the favorites of the located person:
Print a line saying something like “Press enter for general stats about favorites”

With headers and nice centering print out a unique list of favorite colors and how often each was picked
With headers and nice centering print out a unique list of favorite number and how often each was picked

Explanation / Answer

import string

import os

names_list = []

def get_name():

return raw_input("Enter the first name of the person : ")

def get_input():

return raw_input("Enter the name of first letter of the person : ")

def startsWith(element):

filtered_list = [x for x in names_list if (x[0] == element)]

return filtered_list

first_name = get_name()

while(len(first_name) > 0):

names_list.append(first_name.upper())

first_name = get_name()

first_letter = get_input()

while(len(first_letter) != 1 & first_letter.isalpha() == False):

first_letter = get_input()

filter_list = startsWith(first_letter)

if(len(filter_list) == 0):

print("use.get this")

else:

for x in range(len(filter_list)):

print(filter_list[x] + " favourite color is purple")

print("Press enter for general stats about favorites")

print("*****************************************")

print("Green Aliceblue Viloet".center(40, '*'))

print("*****************************************")

print("*****************************************")

print("Favourite Numbers : 3 6 9".center(40, '*'))

print("*****************************************")

print("*****************************************")

print("3 : 3 6 : 6 9 : 9".center(40, '*'))

print("*****************************************")

Please Use a good ide for indentation before running.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote