Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python 3: How do I add input and a string to the same line?

I have to put the input on the same line as the string and can’t figure out how.
Here’s the code:

print('Hello! My name is Awesome Computer.')
print('What is your name?')
name = input()
print('It is good to meet you ' + name + '.')
print('How are you today?')
input()
print('Okay.')
print('I am doing great!')

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The function input() takes in a string to print so you can do this:

name = input("What is your name? ")

And it will print the string before taking input without adding a newline

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading