Write a program that asks the user for their name and how many times to print it. The pro�gram should print out the user’s name the specified number of times.
name = input("Enter your name: ")
num = int(input("Enter a number: "))
for i in range(num):
print(name)
This code will use the input()
function to get the user's name and a number from the user, and then it will use a for
loop to print the name the specified number of times. The int()
function is used to convert the number entered by the user to an integer.
To run this code, you can save it to a file with a .py
extension and run it using the python
command in a terminal or command prompt.
0 Comments