119k views
0 votes
I'm trying to write a python while loop.

while command != 'x':

if command == 'a':

favorite= input('Enter index of movie to add: ')

movies.addToFavorites(favorite)

command = input(options + 'Enter Command (A/R/N/P/J/F/X): ').lower()

elif command == 'f':

favorites= movies.favorites()

print('My Current Favorite Movies:', favorites)

command = input(options + 'Enter Command (A/R/N/P/J/F/X): ').lower()

else:

pass

if command == 'x':

print('End of Program.')


this is what it looks like so far and it's not working. something about the input statement is wrong and it's not looping how i want it to.

User Tuk
by
8.5k points

1 Answer

1 vote

command = ""

while command != 'x':

if command == 'a':

favorite = input('Enter index of movie to add: ')

movies.addToFavorites(favorite)

command = input(options + 'Enter Command (A/R/N/P/J/F/X): ').lower()

elif command == 'f':

favorites = movies.favorites()

print('My Current Favorite Movies:', favorites)

command = input(options + 'Enter Command (A/R/N/P/J/F/X): ').lower()

else:

command = input(options + 'Enter Command (A/R/N/P/J/F/X): ').lower()

if command == 'x':

print('End of Program.')

User Abourget
by
8.3k points

No related questions found