1st code:
number = ["Python" , "Java" , "R" , "C" , "PHP", "Python" , "Java" , "R" , "C" , "PHP"]
num = []
for x in number:
if not x in num:
num += x
print(num)
result : [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’, ‘J’, ‘a’, ‘v’, ‘a’, ‘R’, ‘C’, ‘P’, ‘H’, ‘P’]
2nd code :
number = ["Python" , "Java" , "R" , "C" , "PHP", "Python" , "Java" , "R" , "C" , "PHP"]
num = []
for x in number:
if not x in num:
num.append(x)
print(num)
result :[‘Python’, ‘Java’, ‘R’, ‘C’, ‘PHP’]
please help i’m new to python
I tried to understand but I didn’t so I came here to understand.
I expected both their results to be the same…