-
Notifications
You must be signed in to change notification settings - Fork 33
/
15. common errors.py
88 lines (55 loc) · 1.83 KB
/
15. common errors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'''
Hello and welcome to another python 3 basics video.
In this video we'll be discussing some of the basics to
debugging. In my videos, I get a lot of questions for
help where people have errors and are not sure what
the problem is. If they used some extremely simple debugging,
they'd realize how obvious the answer is.
Most of the time, the problem is a typo, followed closely by
a misunderstanding of indentation and standards.
so standards how are how organize your code. With python,
unlike most languages, you define blocks of code like
functions by indentation. Most python editors will automatically
indent for you where it is necessary. With this, if you are ever
coding along and find python automatically indenting you where
you don't think it should, this should raise a flag for you to
figure out.
(show a basic function... )
There are some more in-depth common-issues that you'll
find from time to time, you can find more debugging videos
by searching for debuggin in my channel. For now I will just
keep these ones basic.
The first error we'll discuss is the NameError: is not defined
'''
'''
As obvious as this might appear to you, this gets people amazingly
frequently. Just learn to recognize the "is not defined"
chances are you typoed the definition of the variable or when you
are referring to it.
'''
variable = 55
#print(varaible)
'''
Next up, we have indentation issues.
You will see "expected an indented block" as a
popup when you never enter an indented block for
something that requires it, like a function.
'''
'''
def task1():
def task2():
print('more tasks')
'''
'''
unexpected indent...
'''
def task():
print ('stuff')
print('more stuff')
print('stuff')
'''
EOL while scanning string literal
'''
def task():
print('some people find themselves committing this too
print('ouch...')