abjer / isds2020

Introduction to Social Data Science 2020 - a summer school course abjer.github.io/isds2020
58 stars 92 forks source link

why some of the variables' names start with numbers in assignment0? #5

Closed fxj483 closed 4 years ago

fxj483 commented 4 years ago

I have heard that the variables should not start with numbers. However, for example, in the section of "0.3 Reusable Code", the two lists' are defined with integer values. These syntaxes work on Jupyter but not on other coding editors. Could someone explain this to me? Thank you in advance!! image image image

jsr-p commented 4 years ago

It is totally legal to define a variable with a variable name including an integer, the integer just can't come as the first part of the variable name. So l1 is syntactically okay but 1l is not. Check out this link for more information.

As to the TypeError that you get when trying to iterate over enumerate(l2), are you sure that l2 is defined as a list containing different characters (as in the notebook) and not as a single integer? This is not related to whether you use jupyter or a simple text file editor.

fxj483 commented 4 years ago

@jsr-p Thank you! I just realized the name of the list is l1 instead of 11. I didn't notice it!