Review, suggestion etc?

Bischoop Bischoop at vimart.net
Thu Dec 17 12:00:45 EST 2020


On 2020-12-17, Michael Torrie <torriem at gmail.com> wrote:
> On 12/17/20 9:10 AM, Bischoop wrote:
>> Could you expand here, I rather don't know how I could do it different
>> way apart from if maritals == 'Yes' or maritals == 'No' or is it what
>> you meant?
>
> I think he's hinting at using a loop instead.
>
> while maritals != 'Yes' and maritals != 'No':
>     maritals = input('Married: Yes/No ?: ').title()
>
> I think I got the logical condition right. Sometimes those are tricky!

I think you're right.
Yes those are tricky sometimes :-)

Look how I had it previously:

    def marriage():
        maritals = input('Married: Yes/No ?: ').title()
        while maritals != 'Yes' and maritals != 'No':
            return marriage()
        return maritals
    marital = marriage()


When looking at it now I couldn't find the dumbest way for it.




More information about the Python-list mailing list