Implement function q1w so that it is just like q1 but uses a while loop instead of a for loop.
def q1(inputString, inputDict, specialValue): s = 0 s2 = 0 a = 0.0 for char in inputString: s = s + inputDict[char] if inputDict[char] == specialValue: s2 = s2 + 1 a = s / len(inputString) return (a, s2)
Implement function q1w so that it is just like q1 but uses a while loop instead of a for loop
inputScreen:
Code:
def q1w(inputString, inputDict, specialValue):
s = 0
s2 = 0
a = 0.0
char=1
while(char<=len(inputString)):
s = s + inputDict[char]
if inputDict[char] == specialValue:
s2 = s2 + 1
char=char+1
a = s / len(inputString)
return (a, s2)
# if any doubt please comment in the comment box...
Get Answers For Free
Most questions answered within 1 hours.