0

I have a list object which can assume a random but finite number of values, ranging from 1 to 638.

Every day I will get a list object with some numbers:

ad-hoc = [1,27,67,300, 450]

I need to create an if statement where depending of the number is the name I am going to assign to a variable. Many of these random numbers are part of the same group so for example:

blue = [ 1,87,34,234]
yellow = [5,78,545,300]

while this reduces the number of ifs I need (so I don't need an if statement with 638 options)

The problem I have if that I need to create probably an OR statement to be able to group numbers and and compare , in pseudo code something like this

for i in ad-hoc:    
    if i == OR(blue):
        print('blue')
    elif i == OR(yellow):
        print('yellow')

What is the best way to structure such an if statement combined with an OR statement

Mariano
  • 295
  • 1
  • 4
  • 13

0 Answers0