Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("""This program determines the color of the chess board box that the user names.
- In order to get thr result , one must enter the correct name of the square like 'e4' or 'b6'
- i.e the first character will be a lower case letter between a-h followed by a digit between 1-8""")
- name = input("Please enter the square name: ")
- letters = ["a", "b", "c", "d", "e", "f", "g", "h"]
- letter = name[0]
- num = int(name[1])
- if letter not in letters or num > 8 or num < 1:
- print("Invalid Input!!! Such box doesn't exist.")
- exit()
- if (num + letters.index(letter)+1) % 2 == 0:
- print(f'Square {name} is black')
- else:
- print(f'Square {name} is white')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement