-3
My algorithm solves the following problem: Create an algorithm that reads 4 typed values and indicates if any pair of numbers sums 8 or a number greater than 8.
s = [int(input()) for c in range(4)]
while sum(s) < 8:
print('Error 01: Erro: A soma de todos os 4 números resulta num número menor que 8, digite outros números.')
s = [int(input()) for c in range(4)]
if sum(s) > 8:
break
x = 0
y = 0
z = 1
s = sum(s[y] + s[z])
while x < 6 or s < 8:
def funcao(x = 0, y = 0, z = 1):
if s == 8:
print(f'Os números {s[y]} e {s[z]} somados dão 8. ')
elif s > 8:
print(f'Os números {s[y]} e {s[z]} somados resultam num número maior que 8. ')
else:
if x == 3 and s < 8:
funcao(x+1,y+1,z+1)
What would be exactly the doubt and what you have below the comment "#here the function would repeat again, only adding 1 to the initial value of variables x, y and z."?
– asfelix
My code ends exactly at this point, because below that would enter the def function that starts in the first comment and ends before the second, but for that I need to know how to add 1 in the value of the variables x, y and z each time the function repeats, and so be able to test if there are any pairs of numbers that add up to 8.
– Lucas Souza
My question is: How to create a def function, so that it adds 1 to the value of the variables x, y and z every time the function repeats.
– Lucas Souza