Python Triple Nested for Loop not Fully Iterating -
essentially happens when run code "print block[j]" section of program gets run, test code have afterwards i.e. print block[k] , print "testing code" not reached. i've been staring @ program last half hour , can't figure out why program can reach beyond 2nd nested loop not third.
def swapii(str): new_str = "" letter in str: if letter.isupper(): new_str = new_str + letter.lower() else: new_str = new_str + letter.upper() new_list = new_str.split(' ') in new_list: block = i.split() j in range(len(block)): print block[j] k in range(j+1, len(block)): print block[k] if block[j].isdigit() , block[k].isdigit(): lala = block[j] block[j] = block[k] block[k] = lala print "testing code" = ''.join(block) return ' '.join(new_list) # keep function call here # see how enter arguments in python scroll down print swapii(raw_input())
Comments
Post a Comment