Python problem about str

Python problem about str
0

#1
number = 0

for number in range(10):
   number = number + 1

   if number == 5:
      break    # break here

   print('Number is ' + str(number))

print('Out of loop')

question
why we are using “str(number)” it 2 nd last line


#2

Because number is an integer, you must convert the number to a string to concatenate it with the first part of the string 'Number is '.


#3

if they wouldn’t converted it into string then an error would be shown because of + operator


#4

You wouldn’t be able to concatenate an int with a str which is why you convert it.


#5

you can keep it as an integer if you removed the “+” and placed “,” instead