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)
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="")
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)
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="")