Example #1

alphabet = "abcdefghijklmnopqrstuvwxyz"

alphabetList = []

for i in alphabet:
    alphabetList.append(i)

print(alphabetList)
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Using a While Loop to Get the Intended Outcome

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
The letter b is the 2 letter in the alphabet

Using a For Loop to Get the Intended Outcome

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
The letter b is the 2 letter in the alphabet

Evens: While Loop

evens = []
i = 0

while i <= 10:
    evens.append(i)
    i += 2

print(evens)
[0, 2, 4, 6, 8, 10]

Odds: While Loop

odds = []
i = 1

while i <= 10:
    odds.append(i)
    i += 2

print(odds)
[1, 3, 5, 7, 9]

Evens: For Loop

numbers = [0,1,2,3,4,5,6,7,8,9,10]
evens = []

for i in numbers:
    if (numbers[i] % 2 == 0):
        evens.append(numbers[i])

print(evens)
[0, 2, 4, 6, 8, 10]

Odds For Loop

numbers = [0,1,2,3,4,5,6,7,8,9,10]
odds = []

for i in numbers:
    if (numbers[i] % 2 == 1):
        odds.append(numbers[i])

print(odds)
[1, 3, 5, 7, 9]

Simultaneous Usage of For Loop and While Loop for Lists

numbers = []
newNumbers = []
i = 0

while i < 100:
    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)
[2, 4, 5, 6, 8, 10, 12, 14, 15, 16, 18, 20, 22, 24, 25, 26, 28, 30, 32, 34, 35, 36, 38, 40, 42, 44, 45, 46, 48, 50, 52, 54, 55, 56, 58, 60, 62, 64, 65, 66, 68, 70, 72, 74, 75, 76, 78, 80, 82, 84, 85, 86, 88, 90, 92, 94, 95, 96, 98]

Challenge Completion

I decided to add more items in order to create a wider options for using the second item (drinks). After successfully fixing the code I decided to add a calculation function to accept more than one item. The code segment now adds the drink (msg) value and the meal (item) value to calculate the total cost of the order.

menu =  {"burger": 3.99,            
         "fries": 1.99,
         "coke": 0.99,
         "sprite": 0.99,
         "devious drink": 0.01,
         "jake from statefarm": 2999.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))
    
while total == 0:
    # item 1: meal (item)
    item = input("What would you like to order?")
    print("Meal:", item.lower())
    for k,v in menu.items():
        if item.lower() == k:
            print("Price: $", menu[item.lower()])
            total = 1
    # item 2: drink (msg)
    msg = input("Would you like to order drinks?")
    print("Drink:", msg.lower())
    for k,v in menu.items():
        if msg.lower() == k:
            print("Price: $", menu[msg.lower()])
            total = 1
    # calculating the total
    print("Total:", menu[item.lower()] + menu[msg.lower()])
    # final message
    print("Thank you for stopping by! Have a nice day!")
Menu
burger  $3.99
fries  $1.99
coke  $0.99
sprite  $0.99
devious drink  $0.01
jake from statefarm  $2999.99
Meal: jake from statefarm
Price: $ 2999.99
Drink: devious drink
Price: $ 0.01
Total: 3000.0
Thank you for stopping by! Have a nice day!