0

Using Python string formatting, my expected output is:

If you took 19 and 13 and added them, you would get 22

However not quite sure if I have done it properly. I keep getting this error:

 Not all arguments converted during string formatting

Could you help please?

Code:

my_age = 19
teenager = 13

print "If you took %s and %s and added them, then you will get %" %(my_age,teenager,my_age + teenager)
1
  • You're missing a specifier after last %. You need: "get %d" Commented Dec 8, 2013 at 1:32

1 Answer 1

1

You're just missing the last 's' after the last % in string

print "If you took %s and %s and added them, then you will get %s" %(my_age,teenager,my_age + teenager)
Sign up to request clarification or add additional context in comments.

1 Comment

@TKA If you get the answer you wanted, don't forget to click the check mark. If the answer is helpful but not quite right, it is polite to honor the OP with a thumbs up.

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.