while i < len(myString): print 'character %d is:'%myString[i] length = len(myString) while i < length: print 'character %d is:'%myString[i] for otherchar in myInput[1:]: if otherchar not in alphas + nums: alphnums = alphas + nums for otherchar in myInput[1:]: if otherchar not in alphnums:
如果在循环里面使用len则会导致多次调用len函数会导致效率低下
如果not in alphas + nums 则每次判断都会进行加法 也会导致效率低下