Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMuhammad Safdar
382 PointsConfused about the use of symbols in python
I am unable to grasp the purpose of using symbols, such as : , {}, .format() etc. Is there any documentation/glossary available explaining their function/use? Thank you
grant Mitchell
6,919 Pointsit's too hard to explain the meaning of the symbols. it's kind of like learning how to walk, you don't think about walking you just do it.
Eddie Licea
1,610 PointsWell this bright teacher of mine in the videos told me to come to the question area to see if I could help someone, even though I just started python 2 days ago lol!
Here is an example from the lesson
age = int(input("How old are you? "))
if age <= 6:
print("Wow you're {}! If you're confident with your reading already...".format(age))
So, how old are you? If you type in a number equal to or less than 6 your number will be put into the {} symbol. Your number will only be able to show up there if you have the .format(age) at the end of your print statement because age is what you want to put into the curly braces {}. Hope that helped lol! :)
Benedict Ojuolape
1,834 PointsI'd advise that each time you see a new symbol introduced, take note of it an write down the explanation described in the video. Then try and actively use the symbol, mess around with it and have fun!
3 Answers
Youssef Moustahib
7,779 PointsIn basics -
':' this is used to say "lets indent everything after this symbol, after this symbol we run some more code
',' this is used to separate bits of data e.g myvariable = "hello" print(myvariable, "hi") hello hi
'{}' this is used in a string. It basically means that you can insert something into it. E.g
"{} Muhammed Safdar".format(myvariable) hello Muhammed Safdar
Hope that helps.
Muhammad Safdar
382 PointsThanks for the comment, Grant Mitchell! I am not giving up at all.
Muhammad Safdar
382 Pointsthanks a lot Youssef!
grant Mitchell
6,919 Pointsgrant Mitchell
6,919 Pointskeep practicing and you'll understand eventually. they are global symbols, when you move on to different languages you will know what to do.