Identifying and Correcting Errors
alphabet = "abcdefghijklmnopqrstuvwxyz"
alphabetList = []
for i in alphabet:
alphabetList.append(i)
print(alphabetList)
print("what letter do you want to check?")
letter = input("Enter letter: ")
if letter == ("a"):
print("1")
if letter == ("b"):
print("2")
if letter == ("c"):
print("3")
if letter == ("d"):
print("4")
if letter == ("e"):
print("5")
if letter == ("f"):
print("6")
if letter == ("g"):
print("7")
if letter == ("h"):
print("8")
if letter == ("i"):
print("9")
if letter == ("j"):
print("10")
if letter == ("k"):
print("11")
if letter == ("l"):
print("12")
if letter == ("m"):
print("13")
if letter == ("n"):
print("14")
if letter == ("o"):
print("15")
if letter == ("p"):
print("16")
if letter == ("q"):
print("17")
if letter == ("r"):
print("18")
if letter == ("s"):
print("19")
if letter == ("t"):
print("20")
if letter == ("u"):
print("21")
if letter == ("v"):
print("22")
if letter == ("w"):
print("23")
if letter == ("x"):
print("24")
if letter == ("y"):
print("25")
if letter == ("z"):
print("26")
letter = input("What letter would you like to check?")
i = 0
while i < 26:
if alphabetList[i] == letter:
print("The letter " + letter + " is the " + str(i+1) + " letter in the alphabet")
i += 1
change str(i) to str(i+1) because a =0
letter = input("What letter would you like to check?")
count = 0
for i in alphabetList:
if i == letter:
print("The letter " + letter + " is the " + str(count+1) + " letter in the alphabet")
count += 1
remove count out of for loop
odds = []
i = 1
while i <= 10:
odds.append(i)
i += 2
print(odds)
changed to i=1 because 1+2, +2, +2, etc will be odd
odds = []
i = 1
while i <= 10:
odds.append(i)
i += 2
print(odds)
changed i=0 to i=1 for same reason as above
numbers = [0,1,2,3,4,5,6,7,8,9,10]
odds = []
for i in numbers:
if (numbers[i] % 2 != 0):
odds.append(numbers[i])
print(odds)
changed evens to odds, replaced == with !=( equal with cannot equal)
numbers = []
newNumbers = []
i = 0
while i <= 100:
if i == 0:
pass
numbers.append(i)
i += 1
for i in numbers:
if numbers[i] == 0:
pass
elif numbers[i] % 5 == 0:
newNumbers.append(numbers[i])
elif numbers[i] % 2 == 0:
newNumbers.append(numbers[i])
print(newNumbers)
added pass if i ==0, replaced if with elif (else), for when number isn't 0
menu = {"burger": 3.99,
"fries": 1.99,
"drink": 0.99}
total = 0
#shows the user the menu and prompts them to select an item
print("Menu")
for k,v in menu.items():
print(k + " $" + str(v)) #why does v have "str" in front of it?
#ideally the code should prompt the user multiple times
item = input("Please select an item from the menu")
second = input("do you want another item")
#code should add the price of the menu items selected by the user
print (menu[item] )
print (check[second])
if second = yes
print (menu[item])
if input = no