A
A
Andrey Godunko2021-01-02 21:27:03
Python
Andrey Godunko, 2021-01-02 21:27:03

How to remove a variable from a function that is in a loop?

import math


def calculation(a_a):
    for i in range(10000):  # до 9999
        b = str(a_a)
        num = []

        q = int(b[0])
        w = int(b[1])
        e = int(b[2])
        r = int(b[3])

        if math.fabs(q - r) == w + e:
            num.extend(f'{q}{w}{e}{r}')


the_a = 1400
calculation(the_a)

the_a = 1600
calculation(the_a)
print(num)

I need to output the num variable. But due to my knowledge of Python, I don't know how

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chegevara_kyc, 2021-01-02
@Noy-name-boy

return(variable name)

def adding(a, b): 
 	# this function is return the value of(a + b) 
  return a + b
print(adding(2,3)) # выведет 5

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question