[Tutor] using the loop function while another

eryksun eryksun at gmail.com
Wed Oct 10 03:14:12 CEST 2012


On Tue, Oct 9, 2012 at 7:39 PM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> another=input('Do you have another book to order for this student?',
>               '\nEnter y for yes: ')

Remove the comma, and this will parse correctly.

A comma in a function call is used to separate arguments. On its own a
comma creates a tuple -- outside of a list or dict and assuming
parentheses for precedence where necessary.

> or you could use triple quotes:
>
>
> another=input('''
>               Do you have another book to order for this student?
>               Enter y for yes: ''')
>


This retains the leading spaces. You can use textwrap.dedent() to remove them:

    >>> print(textwrap.dedent("""
    ...      Do you have another book to order for this student?
    ...      Enter y for yes: """))

    Do you have another book to order for this student?
    Enter y for yes:


More information about the Tutor mailing list