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?
Run python or python3 --version and see what you got installed, your script would run with any version.
Print with parenthesis works on 3+ while without would work on 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With