Page 1 of 1 [ 2 posts ] 

bverjee
Butterfly
Butterfly

Joined: 21 May 2016
Age: 29
Gender: Female
Posts: 12
Location: West Vancouver, B.C., Canada

22 May 2016, 1:52 am

I just started learning Python this month and I have a question:

I want the variable "birthday" to be 7/18/1996. Why can't I make the integers into strings? (see line 4)

line 1: month_born = 7
line 2: day_born = 18
line 3: year_born = 1996
line 4: birthday = (str(month_born) + "/" + str(day_born) + "/" + str(year_born))

I know I can just us "end = "" " and print the slashes separately, but why can't I do it this way?

Thanks;)


_________________
~ Bianca
"Genius is nothing but a great aptitude for patience."


somebody300
Blue Jay
Blue Jay

User avatar

Joined: 8 May 2016
Age: 29
Gender: Male
Posts: 93
Location: France

24 May 2016, 10:59 am

bverjee wrote:
I just started learning Python this month and I have a question:

I want the variable "birthday" to be 7/18/1996. Why can't I make the integers into strings? (see line 4)

line 1: month_born = 7
line 2: day_born = 18
line 3: year_born = 1996
line 4: birthday = (str(month_born) + "/" + str(day_born) + "/" + str(year_born))

I know I can just us "end = "" " and print the slashes separately, but why can't I do it this way?

Thanks;)


Try doing the same, but replace the slashes with something else. If it works, and you still need the slashes, replace them with "\ \".
If you're wondering about the theory behind this, look up the notion of escape characters.