Python - validating and Divisible number

I am receiving a parameter then evaluating what I receive then if I find a multiple of 3, then I multiply it by 3. For example: If your my_ints = [‘0’ ‘0’ ‘3’ ‘0’ ‘1’], my output should be [0,0,30,0,1]
My problem is: My variable “My_ints” is getting the parameter but then when I try to eliminate the “/” or " ", then my line 4 reorder my variable which I dont want. My second problem is I am not getting the outcome I want, instead of having “0,0,30,0,1”, I am getting "0,1,30,

Much appreciated any lights
Thank you,

* import sys
* import re

* my_ints = sys.argv[1:]
* settt_a = {re.sub(r'\W', '', j) for j in my_ints}

* my_newints = [eval (i) for i in settt_a]
* print (my_newints)

* for valida in range (len (my_newints)):
*     if my_newints[valida] %3 == 0:
*         num_divisible = my_newints[valida] * 10
*         my_newints [valida] = num_divisible
* print (my_newints)

You have:

settt_a = {re.sub(r'\W', '', j) for j in my_ints}

It should be:

settt_a = [re.sub(r'\W', '', j) for j in my_ints]

The {...} (braces) are making it a set, but you need [...] (brackets) to make it a list.

Also, don’t use eval, use int instead.

1 Like

THANK YOU Matthew!
It worked