Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试编写一个列表理解,将所有可整除的数字 2 翻倍,将所有可整除的数字 4 翻三倍并省略所有奇数(范围为 1 到 100)。谢谢!
[x*3 if not x%4 else x*2 for x in range(2,101,2)]
def silly_fun(x): if x%4 == 0: return 3*x else: return 2*x [silly_fun(y) for y in data if y%2 == 0]