相关疑难解决方法(0)

在列表理解中使用while循环

说我有一个功能:

x=[]
i=5
while i<=20:
     x.append(i)
     i=i+10
return x
Run Code Online (Sandbox Code Playgroud)

无论如何有这样将其转换为列表理解吗?

newList = [i=05 while i<=20 i=i+10]
Run Code Online (Sandbox Code Playgroud)

我收到语法错误

python list-comprehension list

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

list ×1

list-comprehension ×1

python ×1