multiple conditions to a if loop python
<p>Hello I'm having some problems with some code I am writing for a school and its not working. It wont run through the whole loop but all the code looks right to me. Does anyone have any ideas?</p>

<pre><code>   User_Input = input ( "Please enter a message that is no longer than 7 characters." )
    User_Input_Length = len ( User_Input )  
    if     {  User_Input_Length &gt;= 7 
         and  User_Input_Length == 1
    }:
    print ( "Your message is odd." )
    elif   {  User_Input_Length &gt;= 7
         and  User_Input_Length == 3
    }:
    print ( "Your message is odd." )
    elif   {  User_Input_Legnth &gt;= 7
         and  User_Input_Length == 5
    }:
    print ( "Your message is odd." )
    elif   {  User_Input_Length &gt;= 7
         and  User_Input_Length == 7
    }:
    print ( "Your message is odd" )
    elif   {  User_Input_Length &gt;= 7
         and  User_Input_Length == 2
    }:
    print ( "Your message is even" )
    elif   {  User_Input_Length &gt;= 7
         and  User_Input_Length == 4
    }:
    print ( "Your message is even" )
    elif   {  User_Input_Length &gt;= 7   
         and  User_Input_Length == 6
    }:
    print ( "Your string is even" )
    else:
    print ( "The string is too long." )
    print ( "Goodbye" )
</code></pre>

<p>You're not testing what you think you are. Your expressions look like:</p>

<pre><code>{ User_Input_Length &gt;= 7 and User_Input_Length == 1 }
</code></pre>

<p>In Python, <code>{}</code> encloses a <code>set</code> or <code>dict</code> (or comprehension of either). This is thus a set containing one <code>bool</code> value. Per <a href="https://docs.python.org/3/library/stdtypes.html#truth-value-testing" rel="nofollow">truth value testing</a>, any set that contains members is regarded as True, so your first test will be the only branch taken. </p>

<p>Secondly, the inner (unchecked) condition tests <code>User_Input_Length</code> for simultaneously being 7 or greater <strong>and</strong> some other value; only the one with 7 could ever be true. </p>

python