[Tutor] Formatting Prompts
dn
PyTutor at DancesWithMice.info
Tue Jul 14 22:02:39 EDT 2020
On 15/07/20 10:10 AM, Alan Gauld via Tutor wrote:
> On 14/07/2020 21:11, dn via Tutor wrote:
>
>> preceding print(). Indeed print() offers some automatic formatting 'for
>> free'. However, remember that the default is that it will add an EOL
>> after the printed-string!
>
> But the default can be changed...
True! Apologies, I didn't provide a web.ref for that:
https://docs.python.org/dev/library/functions.html?highlight=print#print
Personal preference: if the prompt-string is somewhat involved (cf "Type
here: ") per the OP's request, is to assign the calculated value to a
string variable (object) and then use that in the input(). Such improves
readability.
That said, that practice can/could/should also be applied in other
situations, because will it eases testing/proving/debugging that block
of code!
--
Regards =dn
More information about the Tutor
mailing list