#can someone help me fix dis, it keeps printing the lowercase x's
1 messages · Page 1 of 1 (latest)
ye its lowercase
sry
i alr fixed it
@floral nest r u a python proffesional
or expeireinced
Not a professional
r u moderate?
But i believe i have above intermediate level experience
Can say that
a = input()
arr = []
i = 0
while i<= len(arr)-1 and a[i] % 2 in ('0', '1', '3', '5'):
a[i] = int(a[i])
arr.append(a[i])
print(arr)```
Mhm what's wrong with that
idk
Well what do you need help with
it only print []
You might want to use a for loop
what
ye
a = int(input())
arr = []
i = 0
while i<= len(arr)-1 and int(a[i]) % 2 == 0 in (1,2,3,4,5):
arr.append(a[i])
print(arr)```
but it doesnt append anything
Ok wait
You are now comparing int(a[i]) % 2 with 0
That will return either True or False
You are then checking if True or False is in (1,2,3,4,5)
what?
int(a[i]) % 2 == 0 in (1,2,3,4,5)
ye
int(a[i]) % 2 == 0
This returns True or False
ye
How will that be in (1,2,3,4,5)
idk
Use parenthesis to make it more clean
where tho
Also you never increment i
It's not a for loop, you have to increase the value of i or it will always stay 0
ok
done
the conditions r alr true so it skips it
i did this
arr = []
i = 0
while i<= len(arr)-1 and a[i] % 2 != 1:
arr.append(a[i])
i += 1
print(arr)```
if the remainder thing is 1 it skips
Also int is not sliceable like that
Don't convert input to int
Let it stay str
Convert to int during the while loop logic and during appending
@floral nest
help me on this
a = input()
arr = []
i = 0
while i<= len(a)-1 and int(a[i]) % 2 == 0:
arr.append(int(a[i]))
i += 1
print(arr)```
Saying it doesn't work or asking what's wrong with this code is not helpful for yourself or others.
Describe what you expect and/or tried (with your code), and what isn't going right.
Please provide any errors you get for optimal assistance.
What do you need help with
i want it to append even numbers
for example
input is 24680
the output
is 24680
0 is not even
but it still prints it
According to python, 0 is even
Check if it is not equal to 0 before doing % 2
how
ok
but it still prints it
eh
if input is 65420
its supposed to only print 6
cuz its the first and even number
cuz teh next interger is odd
Hmm
ehh
done it