#(a) Ask the user for their name and output the name 5 times.
#Extension:
#(b) Allow the user to specify the number of outputs. (1T, 1K)
#a
# Python 3 program to prompt user his/her name and print it 5 times
# Variable to hold name
name = input("Enter your name: ")
# Use for loop to print it 5 times
for x in range(5):
print(name) # Display name
#b Extension
# Python 3 program to prompt user his/her name and number of times to print name
# Variable to hold name
name = input("Enter your name: ")
# Prompt number of times to print the name and cast the input to integer type
number = int(input("Enter the number of times to print the name: "))
# Use for loop to print it depending on the number of times entered
for x in range(number):
print(name) # Display name
Comments
Leave a comment