Hi, I am a beginner in Python programming. I am trying to learn the difference between List and Set, so I created an example using set comprehension to create a Set Z from a list MyList. The set Z will contain boolean values (True/False) based on whether each number in MyList is even or not.

The first example is using set comprehension. On the second example, I used For-Loop to emulate the set comprehension. The results are identical if I add Boolean (True/False) to the set. But when I add String (āTrueā / āFalseā), I have an opposite result.

The expected result is: {False, True}

My result is correct if I add Boolean Value True or False to the set.

actual result = {False,True}

```
SetZ.add(True)
```

However, if I use String Value āTrueā or āFalse,ā I end up with the actual result {āTrueā āFalseā}.

I am unclear why the order is different whether you use Boolean or String.

```
SetZ.add('True')
```

Below is my example:

```
# Uset set comprehension
MyList = [4, 3, 5, 6, 5, 5, 4, 4, 8]
ExpectedSet = {True if n % 2 == 0 else False for n in MyList}
print("expected answer:", ExpectedSet, "\n")
# Use for loop to emulate set comprehension
SetZ = set() # Initialize an empty set
for n in MyList:
condition = n % 2 == 0
if condition:
SetZ.add(True)
print(f"n:{n}=> z.add({condition}), {SetZ}")
else:
SetZ.add(False)
print(f"n:{n}=> z.add({condition}), {SetZ}")
print("Actual SetZ:", SetZ)
```

Output using Boolean

```
expected answer: {False, True}
n:4=> z.add(True), {True}
n:3=> z.add(False), {False, True}
n:5=> z.add(False), {False, True}
n:6=> z.add(True), {False, True}
n:5=> z.add(False), {False, True}
n:5=> z.add(False), {False, True}
n:4=> z.add(True), {False, True}
n:4=> z.add(True), {False, True}
n:8=> z.add(True), {False, True}
Actual SetZ: {False, True}
```

Output using String Value

```
expected answer: {False, True}
Result using String Value
n:4=> z.add(True), {'True'}
n:3=> z.add(False), {'True', 'False'}
n:5=> z.add(False), {'True', 'False'}
n:6=> z.add(True), {'True', 'False'}
n:5=> z.add(False), {'True', 'False'}
n:5=> z.add(False), {'True', 'False'}
n:4=> z.add(True), {'True', 'False'}
n:4=> z.add(True), {'True', 'False'}
n:8=> z.add(True), {'True', 'False'}
Actual SetZ: {'True', 'False'}
```

What am I missing?