[英]finding the resultant which contains the integers
l=list(map(int,input().split(" "))) print(L) s=[] for i in l: if s%3==0 and s%7==0: s+=[ i] 打印
這可以用一個班輪來完成:
l = [x for x in list(map(int,input().split(" "))) if x%3 == x%7 == 0]
這是一個列表生成器,它接受輸入並將其拆分為一個整數列表。 然后在列表生成器中使用此列表,該列表生成器僅包含該列表中可被 3 和 7 整除的元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.