How to use str.format to insert some list elements into formatted string with Python

1 Answer

0 votes
lst = [3, 5, 8, 12]

s = str.format("List values: {v[0]}, {v[1]}, {v[2]}, {v[3]}", v=lst)

print(s)


'''
run:

List values: 3, 5, 8, 12

'''

 



answered Oct 28, 2018 by avibootz

Related questions

...