Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help answer the following questions. 7. Write a function \"wordParser\" t

ID: 3565504 • Letter: P

Question

please help answer the following questions.

7. Write a function "wordParser" that has one parameter a string with groups of characters separated by blanks. The function returns a list with each group as a separate element. For example, assertEqual(wordParser("Here is a sentence"), ["Here sentence") would succeed. Note: This function is already available by the built-in string method split(). For solving this problem, however, you may NOT use split0. You may use other string methods. In future assignments, you may use split()

Explanation / Answer

1)  

def WordParser(s):
   t = ""
   l = []
   for word in s:
       if (word != ' '):
           t += word
       else:
           l.append(t)
   return l
2)
def addDigits(s):
   num = 0
   for words in s:
       if (ord(words) >=48 and ord(words) <= 57):
           num += int(words)
       else:
           print 'Invalid string'
           return
   print 'sum is equal to ',num

3)
def ValidPassword(s):
   upper = 0
   small = 0
   numerical = 0
   special = 0
   if (len(s) >= 7 and len(s) < 15):
       for words in s:
           if (ord(word) >= 48 and ord(word) < 57):
               numerical += 1;
           elif (ord(word) >= 65 and ord(word) <= 91):
               upper += 1;
           elif (ord(word) >= 97 and ord(word) <= 123):
               small += 1
           elif (words == '!' or words == '@' or words == '#' or words == '$' or words == '%' or words == '^' or words == '&' or words == '8'):
               special += 1
   else:
       print 'Invalid Password'
       return
   if (upper > 0 and small > 0 and numerical > 0 and special > 0):
       print 'Valid Password'
       return
   else:
       print 'Invalid Password'
       return