def register_item(): global id_count # Here you are importing the global variable into the function scope print("\n\n\n") print_header('Register new item') title = input('Please type the title: ') category = input('Please type the category: ') price = float(input('Please type the price: ')) stock = int(input('Please type the number of stock: ')) # Validations new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) log_line = get_time().ljust(11) + "| Register Item".ljust(23) + "| " + str( id_count) logs.append(log_line) save_logs() print('Item created')
def register_item(): global id_count #importing the global variable, into function scope print_header(" Regsiter new Item ") title = input("Please input the Title: ") category = input("Please input the Category: ") price = float(input("Please input the Price: ")) stock = int(input("Please input the Stock: ")) #validations new_item = Item() new_item.id = id_count new_item.title = title new_item.category = category new_item.price = price new_item.stock = stock id_count += 1 items.append(new_item) print(" Item Created!! ") log_line = get_time() + " | Register New Item |" + id logs.append(log_line) save_log()