(possible school assignment) Addition not working

#default variables
character_number=int(1)
limit=str("not reached")

v1=str(".")
v2=str(".")
v3=str(".")
v4=str(".")
v5=str(".")
v6=str(".")
v7=str(".")
v8=str(".")
v9=str(".")
v10=str(".")

#imports
import replit
import time 

#Important definitions
def create_limit():
  if character_number<100:
    pass
  else:
    print("You have reached the character limit.")
    time.sleep(1)
    print("Please delete a character if you wish to create more.")
    limit=str("reached")
def create():
  print("Welcome to character creator.")
  time.sleep(2)
  replit.clear()
  create_limit()
  if limit==str("not reached"):
    character_number=(character_number+1)
    print(character_number)
    if character_number==int(1):
      v1=input("Enter the character's name: ")
    
create()
create()

on line 35 addition is not working.

Is this a school assignment ?

ummm i think so lmao

Then i will refrain to answer …

1 Like

Try adding

global character_number

after

def create():

Hope this helps!

Hue :sob: dont give them the answer, this is prob a skool azzinment

@RAYIsaac Is this a school assignment?

Ignore what people are saying about school assignments. We are allowed to help you in a way that lets you learn what you are supposed to be learning.

In this case, it’s probably a scope issue. Variables have a scope in which they can be accessed.

In Python, variables declared outside of a function are available inside that function to be referenced, but not changed.

Here’s a really good article on it: Python Scope & the LEGB Rule: Resolving Names in Your Code – Real Python

4 Likes

It’s good practice to not add str() and int() on to everything

1 Like

It’s not lol, I am doing GCSE computer science but I’m just making this for fun

It’s not, no I’m doing computer science gcse but this is for fun