repl.it
@webbdevvue/

65_Built in Errors

Python

No description

fork
loading
Files
  • main.py
main.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
'''---> IndexError: returns when index doesn't exist'''
friends = ['Billy', 'Jean']
#print(friends[2])

'''---> KeyError: key does not exist'''
movies = {
  'title': 'The Matrix',
  'year': 1999
}
#print(movies['director'])

'''---> NameError: name given for an object is not defined'''
#print(noThing)

'''---> AttributeError: object does not have that attribute'''
enemy = ['JoAnn', 'Bobby', 'Billy']
#friends.intersection(enemy)

'''---> NotImplementedError: can be used when a code block has not been completed or currently being used'''
def myMoney():
  raise NotImplementedError('Not implemented yet')
#myMoney()

'''---> RuntimeError: other errors extend from this error'''

'''---> SyntaxError: incorrect use of syntax'''
class Cool:
  def __init__(self, name, year):
    self.username = name
    #self useryear = year
    
'''---> Indentation Error: improper use of indents'''
def addThis(x, y):
  print(x + y)

'''---> TabError: the mixture of spaces and tabs'''
def mix():
  print('mix') #tabbed
def match():
  print('match') #spaces

'''---> TypeError: operation or function is applied to an object of inappropriate type'''
#print(5 + '2')

'''---> ValueError: problem with the content of the object you tried to assign the value to'''
#print(int('11.5'))

'''---> ImportError: the import creates a loop or does not exist'''

'''---> DepricationWarning: '''