我是python的新手,我有一个任务要完成,但是我找不到方法来完成,所以我请求您的帮助。这是我的任务:我必须从用户那里获取输入,例如:
stackoverflow1.2312312321abcd42ds43
并附加:
-浮点数到floatList
-“42”变成evenList
-43变成oddList
这就是我的代码:
user_input = input("Please enter the text: ")
freeText = ""
floatList = []
evenList = []
oddList = []
for i in user_input:
if i.isdigit():
i += freeText
elif i != "":
floatList.append(i)
主要思想是:
for i in ...
所做的那样)current_number
)。你知道吗has_decimal_dot
)。你知道吗current_number
并继续查看下一个字符。你知道吗current_number
,记住你遇到了一个点。然后,继续看下一个角色。你知道吗current_number
必须是整数,至少如果它的长度大于0。测试模2以知道它是偶数还是奇数。你知道吗current_number
设置为空字符串,将has_decimal_dot
设置为False相关问题 更多 >
编程相关推荐