[英]multiples of a number and greater than “a number” in list
list3 needs to contain values that are 10 times greater than the numbers from baseList that are multiples of 5 and greater than 50. How can I write that? list3 需要包含的值是 baseList 中 5 的倍数且大于 50 的数字的 10 倍。我该怎么写?
It needs to look like this:它需要看起来像这样:
[550, 600, 650, 700, 750, 800, 850, 900, 950, 1000] [550、600、650、700、750、800、850、900、950、1000]
def main():
baseList = list(range(1, 101))
list1 = [x for x in baseList if x % 2 == 0]
print(list1)
list2 = [x for x in baseList if x % 3 == 0 and x <= 50]
print(list2)
list3 = [x for x in baseList if x % 5 == 0 and x >= 50]
print(list3)
main()
baseList = list(range(1, 101))
print [10*x for x in baseList if x % 5 == 0 and x > 50]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.