Python Forum
Why can't this code work.
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why can't this code work.
#3
Typically you want to do this sort of thing with parameters and return statements:
def increment(a):
    return a + 1

x = increment(x)
The value of x is passed as a parameter to the increment function. Internally, increment calls that value 'a'. It adds one to that value and returns it. That become the value of increment(x) in the final line, which is then assigned to x.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Why can't this code work. - by sexualpanda - Feb-05-2017, 06:14 PM
RE: Why can't this code work. - by micseydel - Feb-05-2017, 06:54 PM
RE: Why can't this code work. - by ichabod801 - Feb-06-2017, 04:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  my simple code wont work! help! simon12323121 2 2,043 Sep-05-2021, 09:06 AM
Last Post: naughtyCat
  My code does not work as expected (pygame) rohes_kaugummi 1 1,586 Aug-26-2021, 03:13 PM
Last Post: deanhystad
  I wrote a code but it does not work out as expected chinitayao226 2 1,888 Sep-23-2020, 09:14 PM
Last Post: SnowwyWolf
  A program for backing up documents (doesnt work(code is inside)) Richard_SS 4 3,440 Jun-05-2019, 03:47 PM
Last Post: heiner55
  I Can't Get This Sorting Function In This LinkedList Code To Work JayJayOi 10 7,959 Jan-11-2018, 01:14 AM
Last Post: JayJayOi
  Need help with getting this voting eligiblity code to work Beastly 1 2,539 Aug-16-2017, 03:46 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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