-4

following line gives me headaches:

print 'Total paid ' + round(totalPay, 2)

gives out an error description: "cannot concatenate 'str' and 'float' objects". According to discussion here: Python printing text after printing a variables

the line should be correct. Any hints? Thanks a lot!

Community
  • 1
  • 1
user3774540
  • 11
  • 1
  • 1
  • 3
    Giving you headaches? A simple Google search would have given you the answer immediately. – Peter Jun 25 '14 at 09:54
  • 1
    I did not manage to find the answer by a simple google search. i really spend time on trying to find a solution. notice that in my question, i referred to another discussion. i am very new to python however. hope my abilities to solve such problems without posting questions will improve soon. – user3774540 Jun 25 '14 at 10:01
  • @user3774540 what on earth did you search for?! Just using the error message `"cannot concatenate 'str' and 'float'"` got me 17k results, including the duplicate I just closed this with. – jonrsharpe Jun 25 '14 at 10:05

1 Answers1

1

use:

print 'Total paid ' + str(round(totalPay, 2))

or

print 'Total paid ', round(totalPay, 2)
venpa
  • 4,268
  • 21
  • 23