0
Why is it giving syntax error for creating empty set
9 Respostas
0
Amit Kumar
Corrected code
------
x=list(input())
y=[]
z=[]
print (x)
for i in x:
j = int(i)
if j % 2 == 0:
y.append(j)
elif j % 2 != 0:
z.append(j)
else:
print("somthing unexpected happened")
print("".join([str(i) for i in y]), 'are the even integers')
print("".join([str(i) for i in z]), "are the odd integers")
+ 1
Amit Kumar
You missed one closing braces ) at first line.
+ 1
Ohhhhh thank you so much
+ 1
Amit Kumar One more thing don't write anything inside input () otherwise it will append in list.
Just do
x = list(input ())
+ 1
Thank you soo much
+ 1
Amit Kumar
I have edited my previous reply.
You can do this to join list of integer
print("".join([str(i) for i in y]), 'are the even integers')
print("".join([str(i) for i in z]), "are the odd integers")
0
I Am Groot ! I am unable to use " ".join() on int type
0
What else can I use to join the list
0
Line 6 and 8