There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
Hi @feliperivas598962492!
Good question, did you find the answer?
I also wondering the reason why it does not remove the True and how it works with boolean.
Eww, that’s horribly deceptive, at least you’re aware of it now. @feliperivas598962492 It’s due to the fact that statements like 1 == True == 1.0 evaluate to True in Python. I’d only really heard of it in terms of dictionary keys and sets where similar things are a pain (they have the same hash and no collision) but I suppose it holds true elsewhere.
thanks for your reply! @tgrtim
Now I understand, but what if I needed to remove that argument, how do I identify it? if 1 == True == 1.0 and in the list I have both?
Hmm, the easiest might be to remove it by index, e.g. del example_list[-1] or example_list.pop(index=-1). If you’re looking for a more generic solution where you don’t already know the index the only thing that springs to mind is checking the type of each object and only removing the boolean.
Something like the following could help you find it, you could extend this out with enumerate and a function or something to get the index and work from there.
for elem in example_list:
# some basic type checking
print(isinstance(elem, bool))
print(type(elem) == bool)
Perhaps there’s a cleaner option but it’s not springing to mind at the moment. A good reason to try and limit lists to a single data type where possible I suppose.
how we can append multiple items in a same line of .append( ) function, without creating a new line of .append( ) for adding multiple items in the list