Skip to content

Commit 67fcc1b

Browse files
Python Errors and Quick Fixes
1 parent 858b6ce commit 67fcc1b

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,71 @@ root@omarbelkady: ~$ deactivate
9797
import webbrowser
9898
webbrowser.open("https://www.nelanthecstsffb.com')
9999
```
100+
101+
102+
## Python Errors And Quick Fixes
103+
- ZeroDivisionError: The operation you are trying to perform is not possible because you are dividing by zero. Division
104+
by 0 is not allowed
105+
106+
- EOFError: Compiler hits the End of File and we are trying to use the input() function and we are not allowed to because
107+
of the placement of it.
108+
109+
- FloatingPointError: I am performing an invalid operation with a floating data type value.
110+
111+
- ImportError: The module you are trying to import does not exist
112+
113+
- IndentationError: You are indenting and shouldn't be
114+
115+
- IndexError: You are trying to access an invalid index
116+
L1= [1,2,3]
117+
L1[3]
118+
119+
- KeyboardInterrupt: When I hit CTRL+C shortcut or del key to interrupt the program I am running.
120+
121+
- KeyError: You are trying to access a key that is non-existant within a dictionary aka key-value pair
122+
123+
- MemoryError: We have performed n number of operations and they have used up all our memory.
124+
125+
- ModuleNotFoundError: You are trying to import a module that doesn't exist
126+
127+
- NameError: This is raised whenever you try to use a variable that you have not defined yet locally or globally.
128+
129+
- OSError: A System operation was performed and it triggered a system-related error.
130+
131+
- OverflowError: The arithmetic operation is too large for the declared data type we are performing with.
132+
133+
We can overcome errors by using conditionals: try-except block, if else statement, while loop
134+
135+
- RuntimeError: Error that is raised does not have any category
136+
137+
- StopIteration: Caused when calling the next() method within a for loop and there is no subsequent element to iterate through.
138+
We have reached and the end and within our code we either have not set the limit in our for loop or the limit is too high for the number of elements we are iterating through.
139+
140+
- Syntax Error: You have a typo or are misusing a statement/reserved keyword correctly for example:
141+
```python
142+
while True
143+
print('MY NAME IS OMAR')
144+
```
145+
146+
The above line of code will error because I am missing a colon.
147+
It should be:
148+
```python
149+
while True:
150+
print('MY NAME IS OMAR')
151+
```
152+
153+
- SystemError: When the interpreter detects an internal error
154+
155+
- SystemExit: When you called the sys.exit() function this is triggered
156+
157+
- TabError: You have indented too much and must dedent a places back. Or You must indent. It is parallel with spaces.
158+
159+
- TypeError: This is raised whenever you try to perform an operation with two non-identical datatypes.
160+
161+
The compiler will raise an error telling you you cannot convert the 2nd datatype to the first datatype.
162+
163+
- UnboundLocalError: You are trying to access a local variable which is not defined aka does not exist
164+
165+
- UnicodeError: Unicode Encoding/Decoding Error is taking place
166+
167+
- ValueError: When you pass in a value into a function to perform a computation. The value is the correct data type but of incorrect value

0 commit comments

Comments
 (0)