Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nested Functions
#1
a,b,c = 5,2,3

def f(a):
	def g(b):
		def h(c):
			return a*b*c
		return h
	return g
	print(g)
f(a)	
I'm trying to created nested functions such that the function f includes a print function and when we execute f(a), it prints 30. but this doesn't happen here. Help please!
I know that if i put the print outside the f function and run it as print(f(a)(b)©), it gives the result as 30 too
Reply


Messages In This Thread
Nested Functions - by aditvaddi - Jun-26-2018, 12:07 AM
RE: Nested Functions - by ichabod801 - Jun-26-2018, 03:04 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020