找到整型和字符串,我需要拆分此字符串:從拆分句子
"We shall win 100 dollars in the next 2 years"
,並與整數和字符串([100,2],[We,shall,win,dollars,in,the,next,years])
列表返回一個元組。
我嘗試至今:
lst_int =[]
lst_str =[]
tup_com =(lst_int,lst_str)
words = input_string.split()
for i in words:
if i == int():
lst_int.append(i)
elif i != int():
lst_str.append(i)
return tup_com
非常感謝你的出色解釋。 Merci beaucoup先生! – Wanderer