I'm writing a book for beginners that shows the zodiac signs when you get older.
year_str=input('Please enter the year of your birth in four digits:')
year=int(year_str)
number_of_eto=(year+8)%12
print('Your zodiac sign is',number_of_eto,').')
if you write
Please enter the year of your birth in 4 digits:
and enter the year
('\xe3\x81\x82\xae3\xaa\x81\xaa\x81\x81\x9f\xe3\x81\xae5\xb9\xb2\xe6\x94\xaf\xe3\xe3\x81\xaf',2,'\xe7\x95\xaaa3\x81\xa7\xa7\xe3\x8\xe3\xe3\xa7\x8\x8\x8\x8\x8\
It says
If it's a book, your zodiac sign should say ~, but is there something wrong with the way you wrote it?❓
python python3
If you are using Python 3, this code should print correctly.However, Python 2 prints a string with a lot of backslashes escaped, as shown in the questionnaire.This is related to a change in the way strings are encoded in the program starting with Python 3.0.
So please check your Python version first.For example, you can verify this by entering the following command at the terminal:
python --version
If Python 2.x is installed, that is the reason.There are several solutions.
python3
command exists, use it instead of the python
command.This is a command to run Python 3.x series.
© 2023 OneMinuteCode. All rights reserved.