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
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
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()