Advertisement
biswasrohit20

chess

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