Home > Enterprise >  I'm new to coding & I'm learning python and I wrote some code but there's a function
I'm new to coding & I'm learning python and I wrote some code but there's a function

Time:11-01

If I call this function, it never works, just like it never gets called and without errors, even tho (parameter == 'h') is True, and the help function works, and the function is called properly. I tried everything I could think of.

Function:

def nav(parameter):
    if parameter == 'h':
        help(parameter)

Help Function:

def help(parameter):
    clearConsole()
    print("Help Menu")
    # other code

How I called it:

nav(userInput)

CodePudding user response:

I think this is what you are trying to accomplish :

def nav(parameter):
    if parameter == 'h':
        help(parameter)
    
def help(parameter):
    clearConsole()
    print("Help Menu")
    # other code

import os

def clearConsole():
    command = 'clear'
    if os.name in ('nt', 'dos'):  # If Machine is running on Windows, use cls
        command = 'cls'
    os.system(command)


user_input = input("Enter a character : ")
nav(user_input)

things I added :

  1. user input
  2. clearConsole() method
  • Related