I'm developing a code breaker game where the user is given a coded list and the user has to guess what letter each symbol represents. When the user thinks he has replaced all of the symbols with the correct letters he/she would then type 'check'. What I want my check function to do, is to compare the users list with a separate list with the correct answers but I am stuck on how to do so.
Just use the ==
operator, it calls the method __eq__
on the list which check the elements equality:
>>> a = [1, 2, 3]
>>> b = [1, 2, 3]
>>> c = [1, 2, 3, 4]
>>> a == b
True
>>> a == c
False
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.