New: Practice Python, JavaScript & SQL with AI feedback — Try ActiveSkill free →

Day 10, Bug Fixing Exercise 1

Explanation

Lines 4 and 5 were

number = waiting_list.index(name)

print(f"{name}'s turn is {number}")

but they should be

try: 

    number = waiting_list.index(name)    

    print(f"{name}'s turn is {number}")

except ValueError:

     print(f"{name} is not in the list.")

We use a try-except block to handle the ValueError exception. If that exception occurs, we print out "name is not in the list"

Recommended Course

Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.