jeudi 27 juillet 2017

if statement condition that tests for list membership is not working correctly

I wrote a simple script, but the output is not correct. Can you give me advice how to solve it? the question is about white or black squares on a chess board: If I use the def with a string 'd' and int(4), it will return white, but it has to be black?

def in_white(letter,integer):

    list_letters_1 = ['a','c','e','g']
    list_letters_2 = ['b','d','f','h']

    list_numbers_1 = [1,3,5,7]
    list_numbers_2 = [2,4,6,8]
    print(list_numbers_1)

    if str(letter) in list_letters_1 and int(integer) in list_numbers_1:
        print("black")
    elif str(letter) in list_letters_2 and int(integer) is list_numbers_2:
        print("black")
    else:
        print("white")

in_white('d',4)

Aucun commentaire:

Enregistrer un commentaire