+ 4

str(12) what is this

the number inside the brackets. is it an index??

21st Jan 2018, 6:30 PM
stephen haokip
stephen haokip - avatar
3 Answers
+ 5
no it's not index. it's string parameter
23rd Jan 2018, 3:18 PM
Abishak S
Abishak S - avatar
+ 4
The number isn't an index, more just a parameter. Whatever you put within the brackets of the str() function will turn into a string, which can be helpful in situations where you need user input. You can also do the same with ints by using the int() function, which turns whatever is in the brackets to an int.
21st Jan 2018, 6:35 PM
Faisal
Faisal - avatar
+ 2
Hello. str() returns whatever is in the brackets as a string. str(12) returns "12" (that is, a string, not a number)
23rd Jan 2018, 3:42 PM
Pedro Maimere
Pedro Maimere - avatar