I am using Python 3.6.8. on Ubuntu linux 18.04
I have started a tutorial with simple print statements. The code asks a question requiring input, then outputs the answer.
I have duplicated the last line in the code,as it illustrates the problem
#!/bin/python3
born = input('What year were you born?')
born = int(born)
age = 2025 - born
print(age)
print('In the year 2025 you will be', age, 'years old')
print 'In the year 2025 you will be', age, 'years old'
I expect the result from the first print statement to be; In the year 2025 you will be 75 years old
and the second should give a syntax error (as it is Python 3 and there are no brackets)
What I get is this;
('In the year 2025 you will be', 75, 'years old') In the year 2025 you will be 75 years old
Where is this going wrong?
python3to ran this script?. Bcoz onlypython2will print first as in tuple and second as string.python3should give an error when there is no parenthesis, that's correct. Butpython2can handle both print statements with or without parenthesis. So you are probably running the script usingpython2. Can you provide info how you run the script and what's the output ofwhich python?./filename.pyorpython3 filename.py, it should work fine. But the output shows that you may have run the file usingpython filename.pyandpythonis a symbolic link topython2on many machines.