Say if I had a function which takes several integers such as ("22, 3, 2") and ("3, -8, , 3) as parameters.
Is it possible, and how if possible, to individually check and read each value separated by commas.
Say if I had a function which takes several integers such as ("22, 3, 2") and ("3, -8, , 3) as parameters.
Is it possible, and how if possible, to individually check and read each value separated by commas.
if your parameter to function is a string with comma delimiter you can use split function:
my_data = '22, 3, 2'
parsed = my_data.split(',')
print(parsed) # ['22', ' 3', ' 2']
If you would like to have list of tuples you can use:
print(tuple(parsed)) # ('22', ' 3', ' 2')
You need to use a split, split takes in a "separator" and breaks the string down into an array using the "separator" as an end point:
words = '22, 3, 2'
words2 = words.split(',')
Examples/information: http://www.pythonforbeginners.com/dictionary/python-split