使用Python字符串格式化,我的预期输出是:
If you took 19 and 13 and added them, you would get 22
但不太确定我是否做得恰当。我一直收到这个错误:
Not all arguments converted during string formatting
你能帮忙吗?
代码:
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)
答案 0 :(得分:1)
你刚刚错过了字符串
中最后一个%之后的最后一个's'print "If you took %s and %s and added them, then you will get %s" %(my_age,teenager,my_age + teenager)