How to put word after formula answer?

Question:
I would like to add kr(Swedish currency) after formula answer.
I got error, can’t I have any word after formula answer?
Thank you so much in advance!

My code looks like this:

  a = 5000
  b = 0.8
  c = a * b
  print(c + "kr")

1 Like

You need to convert “c” to a string.
I have three ways to make your print statement on line 22 work:

print(str(c) + "kr")
print(c,"kr") # Note that this method puts a space there by default
print(f"{c}kr") # This is the one that I would do. If for some
# reason it doesn't work and I remembered it wrong, just convert
# that to a string too.
5 Likes

Formatting doesn’t make sense early on but as you have to put more and more variables with strings it becomes a very useful way to keep your code clean and readable.
I would definitely suggest using that method

1 Like

Thank you so muck!!! You made my day!

You’re welcome. If I solved your problem, please mark my post as the solution.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.