This lesson consists of several exercises that combine the different skills you learned in the previous lessons.
In the following question, once you get it correct we'll show you a graphical representation of the output using * graphics.
Use a for loop to find the + character in the string, then extract the substrings before and after the +. Convert them to int and add them.
Although it is possible to use for char in S: to search for the plus sign, it is difficult to extract the substrings with that approach. What we recommend instead is to use a numeric forloop, such as
for position in range(0, len(S)):
which will make it more straightforward.
Along with using substrings and a loop, a key tool is ==, which lets you determine whether two strings are the same.
For an input line of length L, you should add (width-L)//2 periods to the right side.
Break the input into hours and minutes using the same trick as in the Python Adder.
If the original time is H hours and M minutes, the final minutes should be (M+D) % 60. Determining the final hours requires using // 60 and % 24 in the right way.