Study Guide

3.5.4 Fix This Program CodeHS Answers

3.5.4 Fix This Program CodeHS Answers

The most common answer is:

instrument = “kazoo”
age = 7
print “I have played the ” + instrument + ” since I was ” + str(age) + ” years old.”

To fix this program for Python 3 compatibility, you need to use parentheses around the arguments of the print function. Here’s the corrected version:

instrument = "kazoo"
age = 7
print("I have played the " + instrument + " since I was " + str(age) + " years old.")

This code will output:

I have played the kazoo since I was 7 years old.