[英]For and if in print python
我想連續寫這段代碼? 我該怎么寫?
請幫我
b=list(input().split())
a=[]
for c in b:
if int(c)%6==0 and ((b.index(c))+1)%6==0:
a.append(c)
print(*a)
正如 juanpa.arrivillaga 指出的那樣,讓代碼更清晰,而不是將其最小化為一行。
但挑戰接受了:
print(*filter(lambda x: int(x)%6==0, input().split()[5::6]))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.