Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11
This method to format output like this stems from C. Different methods of string formatting, that (roughly) work the same: pi = 3.141592 print('>' + format(pi, '.2f') + '<') #function print(f'>{pi: .2f}<') #literal print('>{:.2f}<'.format(pi)) #method print('>%.2f<' % pi) #operator
5th Jun 2020, 6:04 PM
HonFu
HonFu - avatar
+ 6
Do you know what a format string is? Do you know how the operator % is defined for str? Have you taken a look at RKK's link?
5th Jun 2020, 5:54 PM
HonFu
HonFu - avatar
+ 5
https://python-reference.readthedocs.io/en/latest/docs/str/formatting.html Read this you'll an idea about them!
5th Jun 2020, 5:28 PM
Rohit
+ 4
Works just fine for me. 🤔 Not sure I'm getting your question.
5th Jun 2020, 5:34 PM
HonFu
HonFu - avatar
+ 4
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Basically, those %g at nth position were replaced with formatting arguments at nth index print ("%g is %g" % (3,4)) #Output: 3 is 4
5th Jun 2020, 5:56 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
5th Jun 2020, 6:10 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 3
That's what programming language means. Every syntax and built-in functions and classes will make your coding easy.
5th Jun 2020, 5:35 PM
Sarthak Pokhrel
Sarthak Pokhrel - avatar
+ 3
Nice information
6th Jun 2020, 11:24 AM
Sâñtôsh
Sâñtôsh - avatar
+ 1
Deek, please do not post links that have no relation to the question. This is considered spam. https://www.sololearn.com/discuss/1316935/?ref=app
7th Jun 2020, 8:12 AM
HonFu
HonFu - avatar
+ 1
Please read my code; https://code.sololearn.com/cBgBvDpvsN25/?ref=app. I have edit your code, what you need,. Thanks.
7th Jun 2020, 8:20 AM
Muhammad Sinan
Muhammad Sinan - avatar
7th Jun 2020, 8:18 AM
Muhammad Sinan
Muhammad Sinan - avatar