【发布时间】:2016-11-13 18:17:37
【问题描述】:
我需要拆分这个字符串:
"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
【问题讨论】:
标签: python string python-2.7 python-3.x