PYTHON: enter the number of days after today for a future day and display the future day of the week
<p>I figured out how to code todays date but i am having trouble finding out how to code the future date, if the future date is larger than the integer 6. In the textbook they entered todays date is 0 so it is Sunday. But for days elapsed since Sunday, they entered 31. The result was "Today is Sunday and the future day is Wednesday". I do not understand how this was coded. This is what I have so far.</p>

<pre><code>todaysDate = eval(input("Enter an interger for today's day of the week from 0 - 6, Sunday is 0 and Saturday is 6."))


if todaysDate == 0:
    print("Today is Sunday")
elif todaysDate == 1:
    print("Today is Monday")
elif todaysDate == 2:
    print("Today is Tuesday")
elif todaysDate == 3:
    print("Today is Wednesday")
elif todaysDate == 4:
    print("Today is Thursday")
elif todaysDate == 5:
    print("Today is Friday")
elif todaysDate == 6:
    print("Today is Saturday")



daysElapsed = eval(input("Enter the number of days elapsed since today:"))

if daysElapsed == 1:
    print("Today is Sunday and the future day is Monday")
</code></pre>

<p>Use the modulus operator, <code>%</code>, to divide by 7 and return the remainder of that operation:</p>

<pre><code>&gt;&gt;&gt; 0 % 7
0
&gt;&gt;&gt; 5 % 7
5
&gt;&gt;&gt; 7 % 7
0
&gt;&gt;&gt; 10 % 7
3
</code></pre>

<p>Also, use <code>int()</code> instead of <code>eval()</code> to cast the user's input as an integer. It's much safer.</p>

<p>You can put this together with a <code>list</code> to hold the values instead of a large <code>if</code> block:</p>

<pre><code>days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']

today = int(input("Enter an interger for today's day of the week from 0 - 6, Sunday is 0 and Saturday is 6."))
future = int(input("Enter the number of days elapsed since today:"))
print('Today is {} and the future day is {}.'.format(days[today],
                                                     days[(today+future)%7]))
</code></pre>

python