- 1
python program .. give your answer Input: 23dsa43dsa98 : Output: 23,43,98
which function used to this?
4 ответов
+ 3
... I think they want numbers in an input string be extracted to a list of something. Still, missing attempt by the OP.
You can actually use regex to replace non-numeric groups to a whitespace, and use split to split by whitespace to a list, if that is the case.
+ 3
hi SARANRAJ,
function is replace(). See code sample:
test = '23dsa43dsa98'
out = test.replace('dsa',',')
print(out)
print(test.replace('dsa', ','))
'''
output is:
23,43,98
23,43,98
'''
I used 2 versions: creating a new string with replace and printing direct with replace.
+ 3
print(*re.findall("\d+", input()), sep=",")