cs160examples/week6/inks.py

40 lines
1.2 KiB
Python

def main():
inks = []
toContinue = True
while toContinue:
option = input("Enter an ink? Yes/No: ").lower()
if option == "yes":
inkN = input("Enter the name of the ink: ").lower()
inkC = input("Enter the color of the ink: ").lower()
shimmered = input("Is it shimmered? Yes/No: ").lower()
inks.append((inkN,inkC,shimmered))
elif option == "no":
toContinue = False
else:
print("Sorry, couldn't understand that")
#print(f"These are our ink names {inkNames}")
#print(f"These are the ink colors {inkColors}")
#print(f"This is whether they have shimmer {isShimmered}")
print("Ink Name | Ink Color | Shimmered?")
for n,c,s in inks:
print(f"{n} | {c} | {s}")
# count how many have shimmer
numShimmered = 0
largestNumColors = 0
largestColor = ""
for _,c,s in inks:
if s == "yes":
numShimmered = numShimmered + 1
numTimes = 0
for _,d,_ in inks:
if d == c:
numTimes = numTimes + 1
if numTimes > largestNumColors:
largestNumColors = numTimes
largestColor = c
print(f"You have {numShimmered} inks with glitter. Watch out for clogs.")
print(f"The color you have the most of is {largestColor} and you have {largestNumColors} inks of this color.")
main()