I'm writing a code which takes a string, then splits it up in its characters and then do something depending on the list length. The problem is I don't know how to write it:
If the length (in characters) = 1, 4, 7, 10... (up to 'infinity') execute x code
If the length (in characters) = 2, 5, 8, 11... (up to 'infinity') execute y code
If the length (in characters) = 3, 6, 9, 12... (up to 'infinity') execute x code
What I mean with infinity is either infinity or a big enough number that no human person would be able to write
I've been working with python for a while I and understand how loops/if statements work, but I've never needed to provided an condition like this one where the condition itself comprehends an range of specific numbers up to infinity. One solution would be write three lists with a lots of numbers in them, but I wanna know if there is an easier and less pain taking way of doing it.
decoded is the variable assigned to the input (which is further up on the code)
The mathematical expression for it would be, for the first statement, 1 + 3n, for the second, 2 +3n, and for the third, 3 +3n, being n a real number between 0 and infinity
decodedl = list(decoded)
if len(decodel) == 1 #rest of the stament here
#execute x chunk of code
if len(decodel) == 2 #rest of the stament here
#execute y chunk of code
if len(decodel) == 3 #rest of the stament here
#execute z chunk of code
The expected result is the following:
If I input, for example: 'Hello how are you', then the code should execute code chunk y, as the length of the generated list would be 17: But as it is now, it would do nothing as the length of the list isn't 1, 2 nor 3.