I'm new in Python Language, our professor gave us activity about creating a queue list but I'm very confuse how to do it. The task is to display the movies and snacks that the user entered. Every time it press S the snacks will be remove. I hope someone could explain why this happens and what should I add. Thank you very much.
Movies = [];
movie = str (input ("Enter a movie 1 of 3: "));
Movies.append(movie)
movie = str (input ("Enter a movie 2 of 3: "));
Movies.append(movie)
movie = str (input ("Enter a movie 3 of 3: "));
Movies.append(movie)
Snack = [];
snack = str (input ("Enter snack 1 of 3: "));
Snack.append(snack)
snack = str (input ("Enter snack 2 of 3: "));
Snack.append(snack)
snack = str (input ("Enter snack 3 of 3: "));
Snack.append(snack)
print("Movies to watch are ", Movies);
print("Snacks available are ", snack);
print("Press S each time you finish a snack.");
eat = input();
if str.lower(eat)== "s":
print (snack.pop());
print (snack);
Output:
Enter a movie 1 of 3: Avengers
Enter a movie 2 of 3: Forrest Gump
Enter a movie 3 of 3: Lucy
Enter snack 1 of 3: Milktea
Enter snack 2 of 3: Pizza
Enter snack 3 of 3: Fries
Movies to watch are ['Avengers', 'Forrest Gump', 'Lucy']
Snacks available are fries #this is my problem
Press S each time you finish a snack.
S
In python variables are case-sensitive, in the last part you are overlapping snack
and Snack
so try:
print("Movies to watch are ", Movies);
print("Snacks available are ", Snack);
print("Press S each time you finish a snack.");
eat = input();
if str.lower(eat)== "s":
print (Snack.pop());
print (Snack);