+ 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.
6 Respuestas
+ 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
+ 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'
+ 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
0
I didn't. It consists to make a sentence containing numbers and transform these in strings.
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 ?
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