Write a program to repeat the string "GOOD MORNING" n times. Here ' n ' is an integer entered by the user.
Question
Write a program to repeat the string "GOOD MORNING" $\mathrm{n}$ times. Here ' $\mathrm{n}$ ' is an integer entered by the user.
✨ Free AI Tools for You
Powered by Chatterbot AI
Answer
To write a Python program that repeats the string "GOOD MORNING" 'n' times, where 'n' is an integer entered by the user, you can use the following code:
# Program to repeat the string "GOOD MORNING" n times
# Take an integer input from the user
n = int(input("Enter the number of times you want to repeat 'GOOD MORNING': "))
# Repeat the string "GOOD MORNING" n times
output = "GOOD MORNING " * n
# Print the output
print(output)
This program uses the *
operator to repeat the string and takes the input using the input()
function. The input is then converted to an integer using int()
.
India's 1st AI Doubt Solver for CBSE, JEE, and NEET
Ask a Question for Freeand then it's just ₹212 a month