January 05, 2018 09:07:19Hits:
# Write a function that identifies whether the string matchespythonthe variable name of the syntax# Import KeywordsImportKeywordkey_word = Keyword.kwlistdefPython_grammar (num):# determine the null character enteredifnum = ="": Print ("does not meetpythonnaming rules")returnCount = 0 whileCount < Len (num):# determines whether all characters of a string are numbers or letters or underscores"_"if(Num[count].isalnum () = =True)or(Num[count] is"_"):# determine if it is a keywordifNuminchKey_word:print ("does not meetpythonnaming rules")return# determines whether the first character at the beginning is a numberelifNum[0].isdigit () = =True: Print ("does not meetpythonnaming rules")returnElse: Print ("does not meetpythonnaming rules")return# counterCount + = 1# all the rest is up to the end of the line.Print"Meetpythonnaming rules") Print ("[identify whether a user-entered string matchespythonthe variable name of the syntax]") name = input ("Enter a string:") Python_grammar (name)
Write a function that identifies whether the string conforms to the python syntax variable name