I am back to being confused. I just tried running the module without first importing it, and it worked just fine. How do I do this properly to where the module only runs if I import it?
Code: def MultiplyText(text, multiplier): '''Recieve a S & int. For digits in S, multiply by multiplier and return updated S.''' return ' '.join(str(int(num) * multiplier) if num.isdigit() else num for num in text) def GetUserInput(): '''Get S & multiplier. Test multiplier.isdigit(). Call MultiplyText(text, multiplier)''' text = raw_input('Enter some text: ') while True: multiplier = raw_input('Enter a multiplier: ') try: multiplier = int(multiplier) break except ValueError: continue return MultiplyText(text.split(), multiplier) if "__name__" == '__main__': GetUserInput() What I did in IDLE: >>> >>> GetUserInput() Enter some text: 4 times Enter a multiplier: 2 '8 times' >>> -- Michael J. Lewis mjole...@gmail.com 415.815.7257
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor