Reputation: 1
print("This program is made to check to see if your name has a letter 'a' in it.\n")
list_of_names = ["Cris", "Tom", "Tim", "Cali", "Pearson", "Danny", "Anders", "Britney"]
a_list = []
non_a_list = []
while len(list_of_names) < 11:
input_name = input("What is your name? ")
list_of_names.append(input_name)
#print(list_of_names)
#This Checks if the letter 'a' is in the name and puts them into separate lists.
for name in list_of_names:
if "a" or "A" in name:
a_list.insert(0,name)
elif not "a" and "A" in name:
non_a_list.insert(0,name)
print(f"{a_list} do have an 'a'." )
print(f"{non_a_list} don't have an 'a'." )
I added the empty lists on top and the original list is getting the inputted names but once I print, it doesn't print the two separate lists with the print f I created. yes, I'm a noob. 1 week strong
Upvotes: 0
Views: 26
Reputation: 2006
Changes made: just change the conditions of if else
in checking list_of_names
.
Code:-
print("This program is made to check to see if your name has a letter 'a' in it.\n")
list_of_names = ["Cris", "Tom", "Tim", "Cali", "Pearson", "Danny", "Anders", "Britney"]
a_list = []
non_a_list = []
while len(list_of_names) < 11:
input_name = input("What is your name? ")
list_of_names.append(input_name)
#print(list_of_names)
#This Checks if the letter 'a' is in the name and puts them into separate lists.
for name in list_of_names:
if "a" in name or "A" in name:
a_list.insert(0,name)
else:
non_a_list.insert(0,name)
print(f"{a_list} do have an 'a'." )
print(f"{non_a_list} don't have an 'a'." )
Output:-
This program is made to check to see if your name has a letter 'a' in it.
What is your name? Yash
What is your name? teneth
What is your name? movre
['Yash', 'Anders', 'Danny', 'Pearson', 'Cali'] do have an 'a'.
['movre', 'teneth', 'Britney', 'Tim', 'Tom', 'Cris'] don't have an 'a'.
Upvotes: 0