181k views
5 votes
Write code that prompts the user for a phrase and a number of times to repeat it, then prints the phrase that many times. Here is an example dialogue with the user: What is your phrase? His name is Robert Paulson How many times should I repeat it? 3 His name is Robert Paulson His name is Robert Paulson His name is Robert Paulson

2 Answers

4 votes

‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌‌

User Shersha Fn
by
7.3k points
5 votes

Answer:

phrase=str(input("Waht is your phrase?\\"))#prompting phrase.

rep=int(input("How many times should I repeat it?"))#prompting repetitions integer.

print(phrase*rep)#printing the phrase.

Output:-

What is your phrase?

My name is Mark.

How many times should I repeat it?

4

My name is Mark. My name is Mark. My name is Mark. My name is Mark.

Step-by-step explanation:

I have coded in python language.First I am prompting the phrase form the user in the variable phrase,then I am prompting the integer for repetitions in the variable name rep.Then printing the phrase for rep number of times.

User Nick Shaw
by
8.6k points
Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.