Write a program to repeat the string ‘‘GOOD MORNING”
n times. Here n is an integer entered by the user
Answers
Answered by
2
n = int(input('Enter value: ')) # user input
for i in range(n):
print('GOODMORNING')
mark my answer brainliest
Answered by
1
Answer:
str="GOOD MORNING"
n=int(intput ("Enter the value of n:\n"))
if n>0:
printf(str*n)
else:
printf("Invalid value for n,enter only positive values")
Explanation:
- A string is repeated if its value is greater than zero. Else it will return a blank.
- We will use the 'If' statement to check the value of 'n' first and then the print statement will be executed.
PROGRAM:
str="GOOD MORNING"
n=int(intput ("Enter the value of n:\n"))
if n>0:
printf(str*n)
else:
printf("Invalid value for n,enter only positive values")
OUTPUT:
Enter the value of n: 5
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
GOOD MORNING
Similar questions
Math,
5 months ago
Computer Science,
5 months ago
Math,
5 months ago
CBSE BOARD X,
11 months ago
Math,
11 months ago
Math,
1 year ago