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 trial
spencer tintorri
6,184 PointsHow to tell if something is followed by a colon, a paren, or neither?
Is there a standard way to know if a term is followed by a paren (i.e. print), a colon (i.e. try), or neither (i.e. import, def)?
Thank you.
1 Answer
Steven Parker
243,332 PointsThe parentheses are easy, they go with functions. Any time you invoke a function you must put parentheses after the name. If the function takes one or more parameters, then you put the arguments inside the parentheses.
The colon isn't something I've thought of by itself, I guess I just learned it as part of the syntax. But it does seem that any keyword that works on its own doesn't use a colon. Things that work with other code statements seem to have colons. Like "if" and "else" which control whether the following statement(s) execute, "for" and "while" which cause other statements to loop, and "try" and "except" which set up exception handling while the other statements run.
Those probably aren't the definitive rules you may have been hoping for, but does it help?
Dave StSomeWhere
19,870 PointsDave StSomeWhere
19,870 PointsTo me, the best/standard way is to check the Python Docs.
The strange thing is that every time I go there, I return knowing something new. Enjoy
