jeudi 15 octobre 2020

Check no dups in list and within number range

I am attempting to check a list (of six numbers) for duplicates and that it falls within this number range (inclusive) 20 - 100.

I can get it to work for any number that is less than 20:

 for value in list_input:
        if len(list_input) != len(set(list_input)) or any(i <= 19 for i in list_input): 
            return "Entered incorrect number combination, please try again"
        else: 
            y = combination(81,6)
            return "Your chances of winning are 1:{:,}".format(int(y))

I tried this for line 2, but it doesn't work

if len(list_input) != len(set(list_input)) or any(100 < i <= 19 for i in list_input):

Am I just misunderstanding how List Comprehensions work?

Aucun commentaire:

Enregistrer un commentaire