0

Why i can't format the string (python)

My code: a = (12,13,13) syrs = "result:" for i in range(len(a)): syrs = syrs + " " "{" + str(i) + "}" syrs.format(a[0],a[1],a[2]) print(syrs) But it writes result: {0} {1} {2} not result: 12 13 13

3rd Jul 2019, 12:06 PM
arkasha
2 Respuestas
+ 1
You should try f strings in your programme like this. print(f'result: {a[0]} {a[1]} {a[2]}')
3rd Jul 2019, 12:26 PM
Maninder $ingh
Maninder $ingh - avatar
0
a = (12,13,13) syrs = "result:" for i in range(len(a)): syrs += " "+str(a[i]) print(syrs)
3rd Jul 2019, 12:52 PM
Choe
Choe - avatar