Home > Net >  How do I increment a number that is located in another file in python
How do I increment a number that is located in another file in python

Time:03-19

Okay so i'm trying to make my code increment a number by 1 every time someone goes to another file and in that file make that same number increment by 1 again but i'm having difficulty doing so.

Code in number.py

def number():
  number=0
  print(number)

Code in other1.py

import number

ask = input("Do you want to load another file? ")

if ask == "yes":
  number
  print(number)
  
else:
  print("Okay")

And i'm not really getting an error im just not getting the number that I wanted to see. I want to see 1 but instead I get

<module 'number' from '/home/runner/Idek/number.py'>

CodePudding user response:

As the comments of this post said:

print(number.number())

(nobody put this as the answer so I just did I guess)

  • Related