Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 return variable in func
#!usr/bin/env python3

import sys

def word2(a):
	a1= a+a
	return a1
while True:
	move = input('\'g\' to start\nsomethingelse to quit >>  ')
	move = move.lower().strip()
	if move != 'g':
		word = input('enter 1 word.')
		word = word.lower().strip()

my understanding of return is that once I return a variable it should be usable outside. Regarding my last line, what am I getting wrong...(it really shouldn't need to be defined outside the function). It's in memory, no?
you're not assigning the return value to anything:
it needs a home:
newword = word2(word)
nilamo likes this post

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  call func from dict mcmxl22 3 373 Jun-21-2019, 05:20 AM
Last Post: snippsat
  About [from FILE import FUNC] Nwb 7 420 Apr-21-2019, 02:46 PM
Last Post: snippsat
  script: remove all "carriage return" from my json variable mfran2002 4 814 Feb-20-2019, 05:07 AM
Last Post: mfran2002
  Executing func() from a different folder ebolisa 2 380 Jan-14-2019, 10:18 AM
Last Post: ebolisa
  Pass variable script return twice output problem Faruk 8 513 Dec-26-2018, 11:57 AM
Last Post: Faruk
  Use variable from one function in another without return P13N 3 418 Dec-25-2018, 05:57 PM
Last Post: stullis
  How can I return my list from a func? Mike Ru 3 635 Oct-22-2018, 01:15 PM
Last Post: buran
  Multiple "return" statements or "result" variable? WolfWayfarer 7 1,260 Jul-25-2018, 07:51 AM
Last Post: perfringo
  list func in lambda mepyyeti 1 994 Mar-10-2018, 09:07 PM
Last Post: buran
  How to get parent directory from existing func not user func ? harun2525 3 1,745 May-15-2017, 04:47 PM
Last Post: harun2525

Forum Jump:

Users browsing this thread: 1 Guest(s)