kalpx
kalpx

Reputation: 53

Remove line breaks from user input

I have the following code

UserInput = input("Input a number :")
Numbers = []
for index in range(int(UserInput)):
    print("Entry " + str(index+1) + " is ")
    Numbers.append(input())

I would like the output to look like this

Input a number :2
Entry 1 is 1
Entry 2 is 4

However I get the below using my current code - Python 3.6

Input a number :2
Entry 1 is 

1
Entry 2 is 

4

I guess I am missing something simple somewhere?

Upvotes: 0

Views: 118

Answers (2)

Narendra
Narendra

Reputation: 1539

With reference to your answer:-

UserInput = input("Input a number :")
Numbers = []
for index in range(int(UserInput)):
    print("Entry " + str(index+1) + " is ",end='')
    Numbers.append(input())

Upvotes: 0

kiyah
kiyah

Reputation: 1528

This works:

UserInput = input("Input a number :")
Numbers = []
for index in range(int(UserInput)):
    Numbers.append(input("Entry " + str(index+1) + " is ")) # change here

Upvotes: 1

Related Questions