Python Forum
Python variable and function usage at a time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python variable and function usage at a time
#12
Ah, OK
they complain because we use my_sum also inside the function and their check "thinks" it is hardcoded

def adds_numbers(x, y):
    return x + y
my_sum = adds_numbers(10, 31) 
print(my_sum)
or just use different name inside the function

def adds_numbers(x, y): 
    result = x + y 
    return result
my_sum = adds_numbers(10, 31) 
print(my_sum)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Python variable and function usage at a time - by buran - Sep-24-2020, 01:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  usage of ":" zeppos 1 660 Dec-12-2023, 10:11 AM
Last Post: buran
  Simple animation -- time evolution of function schniefen 0 1,123 Nov-20-2022, 08:05 PM
Last Post: schniefen
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,625 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  Creating a variable that displays time groovydingo 3 3,050 Apr-17-2018, 04:46 AM
Last Post: tannishpage

Forum Jump:

User Panel Messages

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