I have a Python list consisting of integers:
a = [1, 2, 3]
I want to pass the items of this list as arguments to a function, and they must be strings:
myfunc("1", "2", "3")
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
So… we use the
*operator to use a sequence as multiple arguments for a function call; and we want to convert each argument to a string. The conversion is most obviously and simply done by just passing the value to the builtinstr; we can then justmapthat conversion function onto the list. These are all elementary techniques and all we have to do is put them together: