Extra spaces when printing

倖福魔咒の 提交于 2019-12-02 09:13:45

Yes, format your string:

print("... you guessed {}, and ... was {}!".format(math_guess, math_score))

You need to format the entire line into a single string, then print that string.

print ("\n\n\nOn the math section, you guessed {0}, and your actual score was {1}!".format(math_guess, math_score))
print ("\n\n\nOn the math section, you guessed",math_guess,", and your actual score was",math_score,"!", sep ='')

if this is py3+ i think

print ("\n\n\nOn the math section, you guessed"+str(math_guess)+", and your actual score was"+str(math_score)+"!")

should work if not

or use string formatting as others have suggested...

Try this one:

print "\n\n\nOn the math section, you guessed %d and your actual score was %d!" % (math_guess, math_score)

You can read more at Built-in Types

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!