0

What' s wrong about this program?

I'm a Python beginner, so excuse me for stupid questions: See below, I think the output should be 1[9,8,3,6]8, because list[1]==list2[1], as you see in the output, the code understands the list well, so I don't know what's the problem. CODE: import random list=[random.randint(0,9)for x in range(4)] list2=input() a=0 if list[0]==list2[0]: a+=1 if list[1]==list2[1]: a+=1 if list[2]==list2[2]: a+=1 if list[3]==list2[3]: a+=1 else: a=2 print(a,list,list2[0]) INPUT:8888 OUTPUT: 2[9,8,3,6]8

19th May 2022, 8:44 AM
jack
1 Respuesta
+ 3
Your list is of numbers int type data but list2 is string type data so won't match try int(list2[0])
19th May 2022, 8:56 AM
Jayakrishna 🇮🇳