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

Python

spaces

maybe this was clarified but in all the typed code spaces are added fruit = "grape" but I also type fruit="grape" and there are no errors. same as for ints and all variables ect. are the spaces necessary? age=25 years=(age*365) or years = (age *365)

all that might not be just right I just don't want to start a bad habit. But if spaces are not necessary why put them?

2 Answers

Hi Anthony,

As with most languages Python doesn't care for white space in lines, both will resolve to the same thing.

However the difference comes in readability of your code both for yourself and maybe others in the future. Whilst the below are essentially the same, one could be considered easier to read at a glance.

This becomes more apparent as you begin to write more complex code, this essentially comes down to a matter of preference however.

age=25 
years=(age*365)  
years = (age * 365)

Thank you Billy, perfectly explained. I understand. My initial thoughts were why waste the extra key stroke every time...