100 Days of Code: The Complete Python Pro Bootcamp for 2022 - Day 13 (Debugging)
#####DEBUGGING
# Describe Problem: Query is out of range, either change from 1, 20 to 1,21 or 0,21
defmy_function():foriinrange(1,20):ifi==20:print("You got it")my_function()# Reproduce the bug. List index out of range, Change randit (1, 6) to (0, 5)
fromrandomimportrandintdice_imgs=["❶","❷","❸","❹","❺","❻"]dice_num=randint(1,6)print(dice_imgs[dice_num])# Play Computer. Change > and < to >= and <=
year=int(input("What's your year of birth?: "))ifyear>1980andyear<1994:print("You are a millenial.")elifyear>1994:print("You are a Gen Z.")# Fix the Errors
Addinttotheinputint(input("How old are you"))Add=toifage>=18:changeprintstatementindenttoalignwiththeifstatementAddfstringtotheprintstatementage=input("How old are you?"))ifage>18:print(f"You can drive at age {age}.")# Print is Your Friend. Change word_per_page == to word_per_page =
pages=0word_per_page=0pages=int(input("Number of pages: "))word_per_page==int(input("Number of words per page: "))total_words=pages*word_per_pageprint(total_words)# Debugging
# indent b_list.append(new_item)as this line is outside of the function
defmutate(a_list):b_list=[]foritemina_list:new_item=item*2b_list.append(new_item)print(b_list)mutate([1,2,3,4,8,13])
Top comments (0)
Subscribe
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)