+ 3
Does the str() function in Python will take all types of objects as parameters or only the Strings?
>>> str("hello") 'hello' >>> str([1,2,3]) '[1, 2, 3]' >>> str({1,2,"hello"}) "{1, 2, 'hello'}" what does it doing here?
1 Respuesta
+ 5
str() turns stuff into strings. So [1, 2, 3] becomes '[1, 2, 3]' and {1, 2, 3} becomes '{1, 2, 3}'. 😉