Split or extract strings in function arguments?

Suppose I have a function that takes string arguments. But I want to dynamically generate them. It seems that there is no way to easily connect this. How it's done? See my example here

i_take_strings('one', 'two', 'and_the_letter_C') s = 'one two and_the_letter_c' i_take_strings(x for x in s.split()) #python thinks I'm retarded with this attempt 
+4
source share
1 answer

s.split() already returns a list, so you can pass it to the variable arguments function by adding * as follows:

 i_take_strings(*s.split()) 
+5
source

All Articles