Using a function, create a list of 20 numbers randomly between 1-99. With recursive function, you are going to take the numbers from the list, one at a time starting at position 0 and add them together. If the numbers added together equals a user specified sum, stop the program and show the two digits that sum together. I
IN PYTHON:
Using a function, create a list of 20 numbers randomly between 1-99. With recursive function, you are going to take the numbers from the list, one at a time starting at position 0 and add them together. If the numbers added together equals a user specified sum, stop the program and show the two digits that sum together. If not, remove the first number from the list and add the next two. Continue running the program until you have reached the end of the list.
sample output:
randomly selected numbers:
[61, 6, 78, 3, 64, 22, 11, 9, 34, 99, 31, 56, 43, 8, 77, 27, 93, 47, 58, 20]
User input : 86
61 + 6 = 67
FALSE
[6, 78, 3, 64, 22, 11, 9, 34, 99, 31, 56, 43, 8, 77, 27, 93, 47, 58, 20]
6 + 78 = 84
FALSE
[78, 3, 64, 22, 11, 9, 34, 99, 31, 56, 43, 8, 77, 27, 93, 47, 58, 20]
78 + 3 = 81
FALSE
[3, 64, 22, 11, 9, 34, 99, 31, 56, 43, 8, 77, 27, 93, 47, 58, 20]
3 + 64 = 67
FALSE
[64, 22, 11, 9, 34, 99, 31, 56, 43, 8, 77, 27, 93, 47, 58, 20]
64 + 22 = 86
TRUE!
Step by step
Solved in 4 steps with 1 images