Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

can a function output be save as a variable python

#You have to return something in a function to have it in a variable.

def ex_one():
  print('Hi!')
#This won't work.

def ex_two():
  msg = 'Hi!'
  return msg

#This will work.
var = ex_two
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #function #output #save #variable #python
ADD COMMENT
Topic
Name
6+7 =