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

Pycharm quotation issues

So, pretty new with coding in general and im running into an issue. My assignment this week is to run a quick program that takes a name, and age and spit out a quick prompt repeating the name and stating a birth year. the big problem is PyCharm is putting everything in quotations.

So, with my input

user_name = raw_input('Enter your name:')

user_age = int(input('Enter your age:'))

birth_year = (2022 - user_age)

print('Hello', user_name+'!' ' ' 'You were born in', birth_year)

I am getting the output

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

Enter your name:Ryan

Enter your age:27   

('Hello', 'Ryan! You were born in', 1995)


Process finished with exit code 0

Is this just something PyCharm does? I would love to get rid of all the quotation marks, but I also don’t know if im just being too picky about formatting. I appreciate any advice!

>Solution :

You are using a combination of , and + to concatenate strings and some (seemingly) random '. This should work:

print('Hello ' + user_name + '! You were born in ' + str(birth_year))

The problem with your implementation is that python turns your output into a tuple (because of the ,) with the values you are seeing in your output.

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