You can get the list of keywords in the current python version using kwlist method in keyword module. Import the keyword module and try something like this:
#import the keyword module
import keyword
#function to check if the word is a keyword
def isKeyword(word) :
#get keyword list
keyword_list = keyword.kwlist
#check if they word is a prt of the keyword list
if word in keyword_list :
return "Yes"
else :
return "No"
print(isKeyword("Machine"))
print(isKeyword("while"))