+ 3
Why and how, second one is more powerful then 1st one
print("your:" +a) print("your:" .format(a=12)
4 Respuestas
+ 12
There are several options recommended to make an ouput look formatted:
name = 'Paul'
print('Your name is ' + name)
print('Your name is', name)
print(f'Your name is {name}')
The first and the second are sufficient for simple output, the third is f-string and a real powerful version.
Find some information and a comparison of formatting output: https://realpython.com/JUMP_LINK__&&__python__&&__JUMP_LINK-formatted-output/
+ 8
You'll have a better and self-explaining example, if you put three parameters of different data types at three different places within a message:
how_many = 5;
what = "apples";
cost = 4.99;
print("I want to buy " + str(how_many) + what + " for " + str(cost) + " dollars");
print(f"I want to buy {how_many} {what} for {cost} dollars");
print("I want to buy {how_many} {what} for {cost} dollars".format(how_many = 3, what = "bananas", cost = 2.99));
+ 3
Lothar Sandra Meyer I'm really sorry for this late reply since I was reading some documentation as Lothar suggested in previous post and very thankful to both of you from my bottom of my heart 💓, always help me in this manner, and here's some of code if I'm unable to say thank you in future but upvote is for sure
https://code.sololearn.com/ctyd028qg7U9/?ref=app
+ 2
Aww, that's cute Angus👑