-4

When i am tying to take user input in python then it is taking input in next line but I want ti to take input in same line. How to achieve that?

I am taking input like this

print("Enter your name:",end=" ")

It is showing on console as

Enter your name:
Ankit

but I want it as

Enter your name:Ankit
Ankit
  • 95
  • 1
  • 9

3 Answers3

4

You need to use the input method:

response = input("Enter your name:")

(or raw_input for python 2)

Reblochon Masque
  • 35,405
  • 10
  • 55
  • 80
0

By using the input() method Just type,

userinput = input("Enter your name: ")
0

If you are using Python 2.x:

response = raw_input("Enter your name:")

If you are using Python 3.x:

response = input("Enter your name:")

Alternate solution:

For python 2.x:

print("Enter your name:"),
response = raw_input()

For python 3.x:

print("Enter your name:", end="")
response = input()
Kapil
  • 459
  • 3
  • 14