Python challenge | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python challenge

How to make a str from an int ? It begins with a sentence with numbers but how update it with strings ? I try to format it but it is not a good option maybe.

15th Oct 2020, 5:55 AM
Cédric De Craim
Cédric De Craim - avatar
6 Answers
+ 1
Can you clarify your question more? i don't quite understand it. But, if you meant how to use numbers as string you only have to put them in between a quotation mark. Eg. 1 is number '1' is a string
15th Oct 2020, 6:07 AM
E1ias
E1ias - avatar
+ 1
To make an int to str use str() function a = str(2) # a is assigned to '2' Assuming that you want to concatenate just use addition operator. b = a + '3' # value of b is '23' if you want to update by adding a string in middle you can use format c = '1{}4'.format(b) # value of c '1234'
15th Oct 2020, 6:52 AM
Aravind Shetty
Aravind Shetty - avatar
+ 1
You are writing in English but I suppose the meaning is in another language, and you just made a "direct" translation. in English your question is not (at all) clear. It is like: "How to cook potatoes to finally become chips and fish fried but no fish" P.S. it is hard to find black cat in dark room, especially if there is no cat. ©Confutsy
15th Oct 2020, 7:46 AM
Shadoff
Shadoff - avatar
0
I didn't. It consists to make a sentence containing numbers and transform these in strings.
15th Oct 2020, 6:17 AM
Cédric De Craim
Cédric De Craim - avatar
0
@Cedic De Craim is it question or challenge, if it is challenge PLEASE DON'T POST HERE that can be done in the feed and if it is question clarify it ?
15th Oct 2020, 6:18 AM
Ananiya Jemberu
Ananiya Jemberu - avatar
0
do you mean a sentence sentence = ‘one two three’ and numbers nums = [1,2,3] for that check out python library inflect sorry for capitalisation im lazy
15th Oct 2020, 9:15 AM
Matthew Li
Matthew Li - avatar