I am very new to Python but I am working on the Sal’s shipping project Computer Science path python control flow. I am on step 2/3 where I had to build an if elif else object for calculating standard ground shipping. I have run into an error, and have realized that for some reason unlike java, python wants me to put the statements in a very specific pattern of spacing. I have watched the video and also notice that when I built the statements my < and > symbols do not change color from orange to white they are just orange. I don’t think this is part of the error however. So to answer my question, does python evaluate the scope of a question by using specifically spaced questions?
Perhaps the most important spacing is the indentation which is how Python groups blocks of code together. Following an
if statement for example there should be an indent (technically you can squeeze it on the same line without it but it’s generally bad practice) for the suite of code following the clause…
if x > 3: --> do something # that indent is required elif x is not None: # next clause header should not be indented --> do something else # indent this suite again
Spacing between statements tends not to matter except for stylistic purposes. Perhaps I misunderstand your issue though. Consider adding it as a gist/pastebin or on the forums if short- How do I format code in my posts? and any other useful information (link to project if applicable) or error codes if something has gone wrong.
my < and > symbols do not change color from orange to white
Is this what you mean?
No I had an if elfi else statement, and when I supplied the condition for example weight <= 2.0 it would only change the = sign to a white color while the < sign remained as an orange. I ended up resolving the problem by changing the indention of the if statement. I think the color thing was just something with codecademy website.
This helps me thank you, I missed that explanation of forming an if elif statement. I am learning java as well and the way python recognizes scope using less symbols is nice, but its also not as obvious for me.