Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save budgetdevv/8e89704c8f0cfa3deb99ab02ff4bfefe to your computer and use it in GitHub Desktop.
Save budgetdevv/8e89704c8f0cfa3deb99ab02ff4bfefe to your computer and use it in GitHub Desktop.
Q5
#Write your solution (for loop)
toppings = ['sprinkles', 'chocolate syrup', 'whipped cream', 'nuts', 'cherries'];
# Prompt the user to enter a letter
letter = input("Enter a letter to find the first topping starting with that letter: ").lower();
for item in toppings:
if (item[0] == letter):
print(f"First topping starting with '{letter}': {item}");
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment