[font=courier new][size=8pt]There was a mistake in the code above. Now, I have fixed it.
The function, "validvariablename()", was,
[code=python]def validvariablename(s):
s = s.upper()
l = list(s)
ll = len(l)
if ll == 0:
return False
i = 1
for c in l:
if i == 1:
if not c in firstchar:
return False
if i == ll:
if not c in lastchar:
return False
if not c in midchars:
return False
i += 1
return True
[/code]
[font=courier new][size=8pt]It should have been,
[code=python]def validvariablename(s):
s = s.upper()
l = list(s)
ll = len(l)
if ll == 0:
return False
i = 1
for c in l:
if i == 1:
if not c in firstchar:
return False
if i == ll:
if not c in lastchar:
return False
if i > 1 and i < ll:
if not c in midchars:
return False
i += 1
return True
[/code]
[font=courier new][size=8pt]It was only by luck, that it gave the correct answers.
Bookmarks