On 01/10/16 16:12, boB Stepp wrote: >>> This module will take a string and right justify it so that the last >>> character >>> of the line will fall in column 70 of the display. The results will be >>> printed to stdout.''' >>> >> Do you need print_msgs()? >> Won't it work the same with >> >> print(right_justify(input_string)) >>
> I would still need to unpack the arguments returned by right_justify() > that get fed to print(): Ah, I read the assignment spec but not your comment (or code) so didn't notice that your justify function sometimes returns multiple arguments. Personally I don't like functions that sometimes return one and sometimes two results. I'd rather you returned a None first argument in the first case to make it consistent. But given you are returning multiple arguments then yes you need: > print(*right_justify(input_string)) But coming back to the issue of mixing display and logic I'd probably just raise a ValueError if the input string is too long and leave it as a user requirement to check the length of the input or catch the error and display whatever message they felt appropriate. (You can include the error message in the raise if you feel the need) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
