-
Notifications
You must be signed in to change notification settings - Fork 1
/
task1.1.py
50 lines (42 loc) · 1.16 KB
/
task1.1.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
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
>>> for i in range(len(a)):
if(a[i]<5):
myList.insert(b,a[i])
b=b+1
Traceback (most recent call last):
File "<pyshell#5>", line 3, in <module>
myList.insert(b,a[i])
NameError: name 'myList' is not defined
>>> Mylist
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
Mylist
NameError: name 'Mylist' is not defined
>>> MyList()
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
MyList()
NameError: name 'MyList' is not defined
>>> myList=[]
>>> b=0
>>> for i in range(len(a)):
if(a[i]<5):
myList.insert(b,a[i])
b=b+1
>>> print(myList)
[1, 1, 2, 3]
>>> for i in range(len(a)):
if(a[i]<5):
myList.appened(a[i])
Traceback (most recent call last):
File "<pyshell#19>", line 3, in <module>
myList.appened(a[i])
AttributeError: 'list' object has no attribute 'appened'
>>> for i in range(len(a)):
if(a[i]<5):
myList.append(a[i])
>>> print(myList)
[1, 1, 2, 3, 1, 1, 2, 3]
>>>