-6

File "python", line 25 SyntaxError: 'return' outside function

total=0
for key in prices:
    sum=prices[key]*stock[key]
    print sum
    total=total+sum
return total
DeepSpace
  • 78,697
  • 11
  • 109
  • 154

1 Answers1

0

Try relocating this code into a function.

For example:

#!/usr/bin/env python
prices = { 'Python': 100 }
stock = { 'Python': 20 }

def total_portfolio_value():
  total=0
  for key in prices:
    sum=prices[key]*stock[key]
    print sum
    total=total+sum
  return total

total_portfolio_value()
Joe
  • 26
  • 4