Common mistakes in Python


Python is a powerful language that gives the programmer simple and readable code and a lot of liberty. That liberty can turn against you if you don't know some particularities. Here they are:

Misspelled variable name

Sometimes copy and paste can be better. In Python, you need to be careful not to misspell a variable name because you can create another variable instead. In the example bellow, the content of "my_variable" will always be 0:

my_variable = 0
for i in range(0,len(some_int_list)):
    if some_int_list[i] % 5 == 0:
        my_variable = 0
    else:
        my_varaible = 1 # intended misspell


Broadcasting

Broadcasting




<- Back
Next ->

No comments:

Post a Comment

Global Game Jam 2024

Wow, what a weekend. The Global Game Jam is intense. But I and 3 other members manage to build a game for the theme "Make me laugh&quo...