Ardians.sh
Ardians.sh

Reputation: 19

output horizontal loop in python

i have code

even = int(input("total even number : "))
print(even, "first even number : ")
for i in range(2,even*2,2):
    print (i,end=", ")
print(even*2,end=" ")

and output

total even number : 5
5 first even number :
2, 4, 6, 8, 10

while the output I want is like this :

total even number : 5
5 first even number :2, 4, 6, 8, 10

can you help me please?

Upvotes: 0

Views: 472

Answers (1)

SuperStormer
SuperStormer

Reputation: 5387

To avoid printing the trailing newline, change print(even, "first even number : ") to print(even, "first even number : ", end="").

Upvotes: 1

Related Questions