#๐Ÿ”’ Error

12 messages ยท Page 1 of 1 (latest)

vital wadi
#

I'm confused why the code isn't working when it tries to delete

sharp groveBOT
#

@vital wadi

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

vital wadi
#
song = [input(), input(), input(), input(), input()] #User input song
choice = input("Do you want to add a new song? ")
if choice == "Yes":
    add_song = input("Song name: ")
    ranking = int(input("Ranking: "))
    song.insert(ranking - 1, add_song)
    song.pop(5)
    print(f'1. {song[0]}') 
    print(f'2. {song[1]}')
    print(f'3. {song[2]}')
    print(f'4. {song[3]}')
    print(f'5. {song[4]}')

elif choice == "No":
    choice2= input("Do you want to remove a song?")
    if choice2 =="Yes":
        delete_song = input("Song name:")
        if delete_song in song:
            song.remove(delete_song)
        print(f'1. {song[0]}') 
        print(f'2. {song[1]}')
        print(f'3. {song[2]}')
        print(f'4. {song[3]}')
       
    else: 
        print("This song does not exist in the list")
torpid kayak
#

also, the expected ouput includes a 5th song, so I assume that test case is for if they don't want to delete a song

#

if they don't want to delete a song, it should print all five, yes?

vital wadi
#

Yea

#

So add other one?

vital wadi
#

@torpid kayak Do you know how I can fix this from happening?

sharp groveBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Error