An empty line is added at the end, you need to make n-the number of lines

Question:

Python. It is necessary to make n-the number of rows. I succeed, but an empty line is added at the end, how can I remove it?

a = int(input())
phrase = "Hello!"
final = f"{phrase} n"
print (final * a)
Asked By: KefuP

||

Answers:

Your code will look the following:

a = int(input())
phrase = "Hello!"*a
final = f"{phrase} n"
print (final * a,end="")

the code addapted to your task is:

a = int(input())
for i in range(a):
    print("Buy an elephant!")

the result would look like this:

4
Buy an elephant!
Buy an elephant!
Buy an elephant!
Buy an elephant!
a = int(input())
phrase = "Hello!"
final = f"{phrase} n"
print (final * a,end="")
Answered By: KefuP
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.