# str.format() = optional method that gives users # more control when displaying output animal = "cow" item = "moon" print("The "+animal+" jumped over the "+item) # {} = format field print("The {} jumped over the {}".format("cow","moon")) print("The {0} jumped over the {1}".format(animal,item)) # positional arguments print("The {animal} jumped over the {item}".format(animal="cow",item="moon")) # keyword arguments text = "The {} jumped over the {}" print(text.format("cow","moon")) name = "Bro" print("My name is {}".format(name)) print("My name is {:10}".format(name,name)) # amount of padding print("My name is {:10}".format(name,name)) # > = right align print("My name is {:^10}".format(name,name)) # ^ = center align # str.format() = optional method that gives users # more control when displaying output number = 1000 print("The number pi is {:.3f}".format(number)) print("The number is {:,}".format(number)) print("The number is {:b}".format(number)) print("The number is {:o}".format(number)) print("The number is {:X}".format(number)) print("The number is {:E}".format(number))
@MiguelAngel-oz2jp
3 жыл бұрын
How you write ^ ? xd
@thorcoder1
3 жыл бұрын
@@MiguelAngel-oz2jp to centre the name
@MiguelAngel-oz2jp
3 жыл бұрын
@@thorcoder1 I wanted say how write that in my keyboard xd
@farhanishraq7820
3 жыл бұрын
@@MiguelAngel-oz2jp shift + 6
@benjaminjohnpabroquez8012
2 жыл бұрын
animal = 'cow' Item = 'moon' print(f'the {animal} jump over the {item}') Thank me later
@khiemdo5527
2 жыл бұрын
Very great content, and well explain for new programmer. Thanks Bro Code
@samirkarki8880
Жыл бұрын
I didn't understood this first when my Proffessor taught me but you made it easy for me. Thanks Bro!!!
@sehunhan1195
Жыл бұрын
good to have as a reference when you are reviewing someone else's code that uses .format() however, just use f-strings as it is superior in everyway, readability, easier, and faster
@raven4291
Жыл бұрын
Thanks bro! This made my life so much easier!
@PROGame_aisetinski_channel
3 жыл бұрын
Thanks a lot!
@nyiaung4963
5 ай бұрын
very helpful for my study
@OlhaLukashchuk-s9j
9 ай бұрын
I wish we had a professor like you
@pradeepkumarj6135
3 күн бұрын
super bro
@davidchilton23
5 ай бұрын
This video was very helpful. It was very concise and comprehensive (to my knowledge).
@mostafaghobashy2724
Жыл бұрын
good
@neeraj4210
3 жыл бұрын
👍👌
@imadiman528
Жыл бұрын
You're are great I understand it very smoothly 🌹🌹🌹
@krishnavamsinalla
Жыл бұрын
First time watching your video, really great content. Thanks for sharing Bro
@jackw9030
2 жыл бұрын
there is an even nicer way to write this code print(f"The {animal} jumped over the {item} ")
@Darkownercute
2 жыл бұрын
Its true nice
@quick_information101
2 жыл бұрын
You are doing well and you have a great explications
@howardsamuels7695
2 жыл бұрын
Really, really appreciate these easy to follow instructions. I am hoping that we will get some chance to put all of these together and get to use these pieces. Great. Thanks again.
@saebsallam2414
4 ай бұрын
Your awesome man
@chrisnorthall8317
4 ай бұрын
*you're
@tihomirsmoljak7355
Жыл бұрын
bro i just discover u and this is awesome im on my start with python and this is just what i need simple and easy and useful....great job and hope u r still arround im going to check the rest of ur channel and subscribe thanks
@udaysaimanoj2117
2 жыл бұрын
Good content!!
@spartanranger
3 жыл бұрын
Thanks for the video Bro
@danilabakunin6571
Жыл бұрын
Very cool video
@Yu-Gi-Oh36508
Жыл бұрын
i think this video is outdated now, now you can do print(f"the {animal} jumped over the {item}") or maybe it isnt, but either way that way is much easier
@rasheduzzaman_6
11 ай бұрын
our bro is always best
@hyperbeetle2006
Жыл бұрын
Neat.
@NormieDead
5 ай бұрын
thx chad i had forgotin that
@seabiscuitthechallenger6899
8 ай бұрын
👍
@thorcoder1
3 жыл бұрын
Great op sir👍
@airlanggak5391
3 жыл бұрын
thanks man!
@piotrkopcewicz5227
2 жыл бұрын
Significant tutorial !! Thx
@danielmalatji1813
Жыл бұрын
Wow that's all I can say💯💯💯
@kemann3815
2 жыл бұрын
Splendid
@josephthecreator
2 жыл бұрын
Simply AMAZING!
@prannavl3651
Жыл бұрын
Nice video .
@techlace1195
2 жыл бұрын
tnx bro
@zoireshmatov1840
2 жыл бұрын
PYTHON VERY GREAT
@mohammedamirjaved8418
2 жыл бұрын
Love you Bro...
@hailsnover6214
3 жыл бұрын
what about adding blank spaces to numbers?
@LOM-c6f
Ай бұрын
I have a really important question for everybody, Where can I find exercises to practice?
@janlochman1985
Жыл бұрын
What does it mean it's written more elegantly? I don't see the differences.
@beingzero7541
2 жыл бұрын
Wow!
@knownrobloxian3381
2 жыл бұрын
why not do print(f"The {animal} jumped over the {item}")
@melihhopa2684
2 жыл бұрын
hocam süpersiniz devam lütfen
@tarikyassa1076
3 жыл бұрын
Thanks bro!
@kraxpan2618
2 жыл бұрын
thanks bro
@DMcDonald14
2 жыл бұрын
Whoohoooooo
@roxxbloodfallen6743
3 жыл бұрын
Can't we just use f strin
@hamzaammar4356
3 жыл бұрын
you can but he show u more
@manavkumar348
Жыл бұрын
i = 0 while True: if i == 5: while i > 0: i -= 1 print(" "*i, "I just became a Bro") else: i += 1 print(" "*i, "I just became a Bro")
@manavkumar348
Жыл бұрын
Do not run this code
@ankushbhagatofficial
10 ай бұрын
Nice snake
@budderrar5751
Жыл бұрын
noice
@GetNatpavee
2 жыл бұрын
Is this why “{insert thing here}” meme exist?
@shavindasilva
2 жыл бұрын
thanks BROOO!!
@anitaakabogu3997
2 жыл бұрын
thx man
@nikoli6612
3 жыл бұрын
Is Simeone ^468,,. #Stringcode
@mjordan1117
Жыл бұрын
How are these more elegant than the normal + format? My python teacher said the same but I dont understand why. This method seems more stressful to me.
Пікірлер: 72