Home > Software design >  How to put input statement inside a print function?
How to put input statement inside a print function?

Time:10-07

This is the code I did;

print("Enter the letter of package( A, B, C)")
input(": ")

The output of this will be like this;

Enter the letter of package( A, B, C)
: A

I need to make the output look like this;

Enter the letter of package·(A,·B,·C): A

CodePudding user response:

You can just put the printed string inside the input() function:

input("Enter the letter of package( A, B, C): ")

CodePudding user response:

Python’s print() function comes with a parameter called ‘end‘. By default, the value of this parameter is ‘\n’, i.e. the new line character.

We can change it to whatever use-case we have:

print("Enter the letter of package( A, B, C)",end="")
input(": ")

Also it will be better if you store your input in a variable for later usage.

  • Related