Possible Duplicate:
Python concatenate string & list
Is it possible to concatenate a string and a list?
The following code causes the error: TypeError: not enough arguments for format string
t = ["a", "b", "c"]
s = "%s.%s.%s" % t
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.
That could work if you convert your list to tuple like this:
But, python strings has the built in method .join, so, if your list grows, you can handle it like this:
That’s the “pythonic way”, you also should avoid using the + operator with strings, always use .join and format strings. This is because Python Strings (and tuples) are not mutable objects, so, when you’re doing
Python has to allocate new memory to store the new string.
I hope this solved your question