-3

Assuming:

def myfunc(x):
    listv  = []
    listv.append(x)

is there a keyword to stop a variable (listv) from being reassigned? Let's suppose that NRA is a keyword:

def myfunc(x):
    NRA listv  = []
    listv.append(x)

...line will be read and not reassigned but the variable still active appending new values for every function call. I know about the GLOBAL variable, but I just want to know is the keyword exists!

Gahan
  • 4,075
  • 4
  • 24
  • 44
metazord
  • 27
  • 4

1 Answers1

0

Variables in functions are not supposed to be persistent between function calls. Because functions are meant to be reusable codes that can be called from different context in the program. So to your answer, NO! There's no keyword for making a variable declared in function persistent.

Maker Jr
  • 13
  • 3