Python Popcorn and Homework Hacks

#Popcorn Hack 1

number = 5

while number > 0: # Make sure hello only prints 5 times
    print("Hello") # Print to terminal
    number -= 1 # subtract one to lower counter number
Hello
Hello
Hello
Hello
Hello
# Popcorn Hack 2

name_repeat = 0 # reset counter

while name_repeat < 4:
    # Print first name
    print("Risha")

    name_middle = 0 # Middle name Counter
    while name_middle < 2: 
        print("N/A")
        name_middle += 1
        # Print middle name 2 times

    name_last = 0 # Last name counter
    while name_last < 3:
        print("Guha")
        name_last += 1  
        # Print last name 3 times

    #repeat whole thing 4 times
    name_repeat += 1
Risha
N/A
N/A
Guha
Guha
Guha
Risha
N/A
N/A
Guha
Guha
Guha
Risha
N/A
N/A
Guha
Guha
Guha
Risha
N/A
N/A
Guha
Guha
Guha
# Popcorn Hack 3

name = "Risha"

for i in name: 
    print(i) # print each letter in name
R
i
s
h
a
# Popcorn Hack 4

myGroup= { 
    "player1": "Risha",
    "player2": "Vibha",
    "player3": "Ava",
    "teacher": "Mr. Brown" 
} # Define dictionary about my group

for key, value in myGroup.items(): # print each key and value in the statement below
    print(f"The key is {key} and the value is {value}.")
The key is player1 and the value is Risha.
The key is player2 and the value is Vibha.
The key is player3 and the value is Ava.
The key is teacher and the value is Mr. Brown.
# Homework Hack 1

# Define password
password = "CyberPatriot1!"

# Control while loop
isPasswordCorrect = False

# While loop doesn't proceed until password is correct
while not isPasswordCorrect:
    # Ask for password
    userInput = input("Enter password: ")

    # Check for password correct
    if userInput == password:
        print("Correct password. Logging you in... ")
        isPasswordCorrect = True # Exit loop

    else:
        print("Wrong password. Try again or press 'Forgot Password' to reset it.")

Wrong password. Try again or press 'Forgot Password' to reset it.
Correct password. Logging you in... 
# Homework Hack 2

name = input("Enter your name: ")

for i in name: 
    print(i) # print each letter in name
n
a
m
e
-
h
e
r
e
# Homework Hack 3

# list fruits
fruitList = ["apple", "banana", "grape", "kiwi", "mango", "strawberry", "raspberry"]

# List each fruit by iterating

for i in fruitList:
    print(i)
apple
banana
grape
kiwi
mango
strawberry
raspberry