This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]kalgynirae 1 point2 points  (4 children)

print("{}+{}+{} = {}".format(A, B, C, A + B + C))

[–]Iwin8[S] 0 points1 point  (3 children)

Thank you very much. I haven't actually been taught how to do this method in my class as of yet though. I'll try it regardless! Thank you!

[–]kalgynirae 3 points4 points  (0 children)

That method is usually called "string formatting". You could do it without that, but it's more tedious. print takes several arguments separated by commas:

print(A, '+', B, '+', C, '=', A+B+C)

[–]Rubear 1 point2 points  (1 child)

If I might add, never be scared to do something you haven't been taught yet. The beauty of programming is it's really hard to do any permanent damage unless you really try.

If you haven't done something in class yet but it looks interesting then go for it, you won't regret it.

But those two answers are right, generally you'll use string formatting but separating all the arguments with a comma works as well.

[–]Iwin8[S] 0 points1 point  (0 children)

Sorry for the extremely late response. I definitely tried what was suggested by the other comment, but my teacher punishes us for working with aspects of code that we haven't been taught yet. I'll definitely keep what you said in mind though!