I only started to code a few days ago and have been doing the python 3 course. I have a question that has followed me through some of the modules.
If i were to run the exact example i would get an error. Here is an example:
result = divide_by_four(16)
print("16 divided by 4 is " + str(result) + “!”)
result2 = divide_by_four(result)
print(str(result) + " divided by 4 is " + str(result2) + “!”)
And here is my code that worked:
def calculate_age(current_year, birth_year):
age = current_year - birth_year
my_age = calculate_age (2049, 1993)
dads_age = calculate_age (2049, 1953)
print("I am “+str(my_age) +” years old " +“and my dad is “+str(dads_age) +” years old”)
As you can see, my code does not have spaces between "+str(my_age) and so on. I would like a clarification on whats actually correct and why?
Hope someone can help me understand this.