100일 간의 코드: 2022년을 위한 완전한 Python Pro 부트캠프 - 13일차(디버깅)
#####디버깅
# Describe Problem: Query is out of range, either change from 1, 20 to 1,21 or 0,21
def my_function():
for i in range(1, 20):
if i == 20:
print("You got it")
my_function()
# Reproduce the bug. List index out of range, Change randit (1, 6) to (0, 5)
from random import randint
dice_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?: "))
if year > 1980 and year < 1994:
print("You are a millenial.")
elif year > 1994:
print("You are a Gen Z.")
# Fix the Errors
Add int to the input int(input("How old are you"))
Add = to if age >= 18:
change print statement indent to align with the if statement
Add f string to the print statement
age = input("How old are you?"))
if age > 18:
print(f"You can drive at age {age}.")
# Print is Your Friend. Change word_per_page == to word_per_page =
pages = 0
word_per_page = 0
pages = int(input("Number of pages: "))
word_per_page == int(input("Number of words per page: "))
total_words = pages * word_per_page
print(total_words)
# Debugging
# indent b_list.append(new_item)as this line is outside of the function
def mutate(a_list):
b_list = []
for item in a_list:
new_item = item * 2
b_list.append(new_item)
print(b_list)
mutate([1,2,3,4,8,13])
Reference
이 문제에 관하여(100일 간의 코드: 2022년을 위한 완전한 Python Pro 부트캠프 - 13일차(디버깅)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/mike_kameta_aed62d48c2d0f/100-days-of-code-the-complete-python-pro-bootcamp-for-2022-day-13-1bj4텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)