T
T
Timebird2016-02-16 19:28:55
Python
Timebird, 2016-02-16 19:28:55

How to operate on the value received by a function in Python?

Good evening.
Such a question - the result of the function is a list:

def vhod(s):
  a = input().split() #тут строка переводится в число
  for i in range(len(a)):
    a[i] = int(a[i])
  s = []
  for i in range(a[0], a[-1]+1, 1):
    s.append(i)
  print(s) #выводятся все числа от первого эл-та списка до последнего

How can I assign this list to a variable so that we can continue to perform operations on it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Martyanov, 2016-02-16
@Timebird

The magic word return will probably save you.

O
Oscar Django, 2016-02-17
@winordie

How to substitute an array into a function?
maybe you should read the answers to your own questions?

def vhod():
  a = input().split() #тут строка переводится в список строк
  a = list(map(int, a)) # тут список строк превращается в список чисел
  print(a) #выводятся все числа от первого эл-та списка до последнего
  return a

map(lambda l: l*2, my_list)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question