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
2 Respuestas
+ 1
You should try f strings in your programme like this.
print(f'result: {a[0]} {a[1]} {a[2]}')
0
a = (12,13,13)
syrs = "result:"
for i in range(len(a)):
syrs += " "+str(a[i])
print(syrs)