+ 1

How can i add commas in between numbers which come as an output

Eg :- 10000000 into 10,000,000 https://code.sololearn.com/co57aH1MVxRv/?ref=app

22nd Oct 2023, 3:27 PM
P A Arrchith Iyer
P A Arrchith Iyer - avatar
2 Respuestas
+ 9
P A Arrchith Iyer , you can use a f-string to format and do the desired output: num = 10000000 print(f'{num:,}') output will be: 10,000,000
22nd Oct 2023, 3:56 PM
Lothar
Lothar - avatar
+ 3
#To write code, you can use an underscore: num = 10_000_000 #To output data together with a variable in a formatted string, either with an underscore or with a comma: print(f'{num = :,}')
22nd Oct 2023, 5:21 PM
Solo
Solo - avatar