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

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 1:

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.

Solution 2:

Well, for starters, it looks like you’re using python 2. This is generally a bad idea when you start, as python 3 is used much more. But to answer your question, you aren’t printing out one string. Instead, you are printing a string ‘Hello ‘ then a completely different string, then an integer. The best way to print multiple variables in the same string is to use the built-in f’’ command. Simply use print(f’Hello, {user_name}! You were born in {birth_year}.’). However, I’m not sure if this is compatible with python 2.