Skip to content
Exercises · Q16

Q.Write a program to repeat the string ‘‘GOOD MORNING” n times. Here ‘n’ is an integer entered by the user.

West Bengal WbchseTextbookSubjective· 2mImportance★★★★★est
88% · 43/49 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Read n with int(input(...)) and print "GOOD MORNING" n times — either with a for-loop over range(n) or with the string repetition operator *.

The concept here is string repetition: Python's * operator, applied to a string and an integer, repeats the string. The same task can be done with a loop, which is the more general pattern.

Method 1 — loop (prints the message on n separate lines):

n = int(input("Enter n: "))
for i in range(n):
    print("GOOD MORNING")

Method 2 — string repetition (one expression):

n = int(input("Enter n: "))
print("GOOD MORNING\n" * n)

Here "GOOD MORNING\n" * n builds one long string containing the message n times, each followed by a newline, and prints it in one go. (Without the embedded newline, "GOOD MORNING" * n would run the words together on a single line: GOOD MORNINGGOOD MORNING….) …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.