0

I added a single parameter to the function, as well as multiple parameters. I also moved the variables outside of the function and I get an error each time. is str() needed?

def g_chord():
  string_1 = "G note"
  string_2 = "B note"
  string_3 = "D note"
  print "A 'G' chord consists of the 1st, 3rd, and 5th notes in the G scale.  Those notes are a, %d, %d, and %d." % (string_1, string_2, string_3)

g_chord()
1
  • 2
    replace %d with %s Commented Oct 19, 2017 at 17:58

2 Answers 2

3

%d is used for numbers. Use %s instead.

Sign up to request clarification or add additional context in comments.

Comments

0

If you try to print a string with %d it will give you and error.

Traceback (most recent call last):
File "<stdin>", line 5, in <module>
TypeError: %d format: a number is required, not str

so try replacing those %d with %s. print "A 'G' chord consists of the 1st, 3rd, and 5th notes in the G scale. Those notes are a, %d, %d, and %d." % (string_1, string_2, string_3

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.