Hope Rouselle <hrouse...@jevedi.com> writes: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> Hope Rouselle <hrouse...@jevedi.com> writes: >>>How would you write this? >> >> """Rolls two dice until both yield the same value. >> Returns the number of times the two dice were rolled >> and the final value yielded.""" >> roll_count = 0 >> while True: >> outcome = roll_two_dice() >> roll_count += 1 >> if outcome[ 0 ]== outcome[ 1 ]: break >> return roll_count, outcome[ 0 ] > > You totally convinced me. Thanks.
Wait, I'm surprised ``outcome'' is still a valid name at the return-statement. Wasn't it defined inside the while? Shouldn't its scope be restricted to the while block? I had no idea. I should learn some Python. -- https://mail.python.org/mailman/listinfo/python-list