repl.it
@m1s5ed/

some name

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
51
52
53
54
55
#L = [42, 6, 82, 4.3, -4.3, 4.30, 0, 4]
#for i in range(2, len(L), 3):
#  print('the current element is', L[i])
def is_odd(n):
  if n % 2 == 1:
    return True
  elif n % 2 == 0:
    return False 


def is_odd(n):
  if n % 2 == 1:
    return True
  return False



def is_odd(n):
  return n % 2 == 1

def is_even(n):
  return not is_odd(n)
  
def counter(L, f):
# count the number of elements of L that make the functions of f true 
  count = 0
  for num in L:
    if f(num):
      count += 1
  return count 


>>> L = [1,2,3]
>>> I = [4,5]
>>> L + I
[1, 2, 3, 4, 5]
>>> L.append(4)
>>> L = L.append(5)
>>> L= L.append(6)
>>> L
>>> type(L)
<class 'NoneType'>
>>> L = [1,2,3]
>>> l.append(4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'l' is not defined
>>> L.append(4)
>>> L
[1, 2, 3, 4]
>>> L.pop()4
>>> L
[1, 2, 3]
>>>
Fetching token
?