def double(sequence)
File "/tmp/ipykernel_3277/595388361.py", line 1 def double(sequence) ^ SyntaxError: invalid syntax
def double(sequence):
result = []
for element in sequence:
result = result + [element * 2]
return result
double():
def
for
File "/tmp/ipykernel_3277/2049100046.py", line 1 double(): ^ SyntaxError: invalid syntax
double([1, 10, 5])
[2]
double([-42, 0, 42])
[-84]
double ([-42, 0, 42, -43, 1, 43, -44, 2, 44])
[-84]
double([-42, 0, 42, -43, 1, 43, -44, 2, 44])
[-84]
ddouble([24])
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_3277/3573500370.py in <module> ----> 1 ddouble([24]) NameError: name 'ddouble' is not defined
double([])
double()
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/2608569975.py in <module> ----> 1 double() TypeError: double() missing 1 required positional argument: 'sequence'
double of whatever is inside the parentheses
x = [1, 2, 3]
double(x)
[2]
x
[1, 2, 3]
double(y)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_3277/141114915.py in <module> ----> 1 double(y) NameError: name 'y' is not defined
y = [4, 5, 6]
double(y)
[8]
y
[4, 5, 6]
double([])
double()
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/2608569975.py in <module> ----> 1 double() TypeError: double() missing 1 required positional argument: 'sequence'
double(1)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/438741259.py in <module> ----> 1 double(1) /tmp/ipykernel_3277/199631824.py in double(sequence) 1 def double(sequence): 2 result = [] ----> 3 for element in sequence: 4 result = result + [element * 2] 5 return result TypeError: 'int' object is not iterable
double([1])
[2]
double([4])
[8]
double5
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_3277/4018363604.py in <module> ----> 1 double5 NameError: name 'double5' is not defined
double([1,2]) ([3,4])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/3264468326.py in <module> ----> 1 double([1,2]) ([3,4]) TypeError: 'list' object is not callable
double([1,2]),([3,4])
([2], [3, 4])
double([1, 2, 3])
[2]
double[(1,2),(3,4)]
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/2513949689.py in <module> ----> 1 double[(1,2),(3,4)] TypeError: 'function' object is not subscriptable
double([1,2],[3,4])
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/454235635.py in <module> ----> 1 double([1,2],[3,4]) TypeError: double() takes 1 positional argument but 2 were given
def triple(sequence):
result = []
for element in sequence:
result = result + [element * 3]
return result
triple([2])
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_3277/2117034568.py in <module> ----> 1 triple([2]) NameError: name 'triple' is not defined
triple([1, 2, 3])
[3]
triple([1, 2])
[3]
triple([3, 4])
[9]
triple(1)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/1973563534.py in <module> ----> 1 triple(1) /tmp/ipykernel_3277/1845490265.py in triple(sequence) 1 def triple(sequence): 2 result = [] ----> 3 for element in sequence: 4 result = result + [element * 3] 5 return result TypeError: 'int' object is not iterable
triple(1,2)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/3983919233.py in <module> ----> 1 triple(1,2) TypeError: triple() takes 1 positional argument but 2 were given
triple([1,2])
[3]
triple([2])
[6]
triple([3])
[9]
triple([4])
[12]
triple([3])
[9]
triple[3, 1])
File "/tmp/ipykernel_3277/1539740136.py", line 1 triple[3, 1]) ^ SyntaxError: invalid syntax
triple[(3,1)]
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/3022748211.py in <module> ----> 1 triple[(3,1)] TypeError: 'function' object is not subscriptable
triple([3,1])
[9]
triple([3,2])
[9]
triple([9])
[27]
def quadruple(sequence):
result = []
for element in sequence:
result = result + [element * 4]
return result
quadruple(2)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_3277/3583553227.py in <module> ----> 1 quadruple(2) /tmp/ipykernel_3277/900360179.py in quadruple(sequence) 1 def quadruple(sequence): 2 result = [] ----> 3 for element in sequence: 4 result = result + [element * 4] 5 return result TypeError: 'int' object is not iterable
quadruple([2])
[8]
quadruple([4])
[16]
triple([2, 3, 4])
[6]