Answer the question
In order to leave comments, you need to log in
Why doesn't the list transformation function work?
I give the input of the function a list that it transforms:
1) First it leaves only even numbers
2) It divides the remaining even numbers by 2
The function does nothing with the list, tell me why?
I enter 2 3 4. I expect the result [1, 2], but in fact the same list [2, 3, 4]
def modify_list(l):
m =[]
for z in l:
if z % 2 == 0:
m.append(int(z // 2))
return m
l = [int(i) for i in input().split()]
modify_list(l)
print(l)
Answer the question
In order to leave comments, you need to log in
Looks like my subd doesn't support from
, here's what it looks like if it works:
UPDATE
oc_decomo_items di
LEFT JOIN oc_product p
ON p.product_id=di.product_id
SET
di.product_id=NULL,
di.add_to_shop=0
WHERE
di.product_id IS NOT NULL
AND p.product_id IS NULL
Here the condition is strange:
di.product_id IS NOT NULL
AND p.product_id IS NULL
At the same time:
p.product_id=di.product_id
Here one field is always required . NULL, while the second is always non-NULL and the p.product_id=di.product_id condition will never be met.
Works for third version of python:
def modify_list(l):
tmp = [el for el in l if not el%2]
l.clear()
l.extend(tmp)
for i in range(len(l)):
l[i] //= 2
l = [int(i) for i in input().split()]
modify_list(l)
print(l)
Never use the characters 'l' (lowercase letter el), 'O' (uppercase letter oh), or 'I' (uppercase letter eye) as single character variable names.
In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use 'l', use 'L' instead.
def modify_list(l):
m =[]
for z in l:
if z % 2 == 0:
m.append(int(z // 2))
return m
l = [int(i) for i in input().split()]
a = modify_list(l)
print(a)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question