String formatting | Sololearn: Learn to code for FREE!

+1

String formatting

# string formatting nums = [4, 5, 6] msg = "Numbers: {} {} {}". format(nums[0], nums[1], nums[2]) print(msg) output: Numbers: 4 5 6

5/11/2020 9:14:28 AM

Taofeeq Olawale

3 Answers

New Answer

+2

Yea, I know but what are the differences compare to below program # string formatting nums = [4, 5, 6] msg = "Numbers: {0} {1} {2}". format(nums[0], nums[1], nums[2]) print(msg)

+1

Taofeeq Olawale Output will be 4 5 6 https://www.sololearn.com/learn/Python/2455/

0

Taofeeq Olawale It's working, what's the problem