简体   繁体   中英

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?

It needs to look like this:

[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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM