Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,864 questions

51,786 answers

573 users

What is the tostring() equivalent in Python

6 Answers

0 votes
n = 15

s = str(n)

print(s, type(s))




'''
run:

15 <class 'str'>

'''

 



answered Apr 13, 2021 by avibootz
0 votes
lst = [1, 2, 3, 4]

lst = str(lst)

print(lst, type(lst))




'''
run:

[1, 2, 3, 4] <class 'str'>

'''

 



answered Apr 13, 2021 by avibootz
0 votes
lst = [1, 2, 3, 4]

lst = "{}".format(lst)

print(lst, type(lst))




'''
run:

[1, 2, 3, 4] <class 'str'>

'''

 



answered Apr 13, 2021 by avibootz
0 votes
n = 15
 
s = "{}".format(n)
 
print(s, type(s))
 
 
 
 
'''
run:
 
15 <class 'str'>
 
'''

 



answered Apr 13, 2021 by avibootz
0 votes
n = 15
 
s = f'{n}'
 
print(s, type(s))
 
 
 
 
'''
run:
 
15 <class 'str'>
 
'''

 



answered Apr 13, 2021 by avibootz
0 votes
lst = [1, 2, 3, 4]
 
lst = f'{lst}'
 
print(lst, type(lst))
 
 
 
 
'''
run:
 
[1, 2, 3, 4] <class 'str'>
 
'''

 



answered Apr 13, 2021 by avibootz

Related questions

1 answer 173 views
1 answer 114 views
1 answer 149 views
4 answers 303 views
1 answer 216 views
1 answer 180 views
1 answer 96 views
...