mardi 28 septembre 2021

Only the functions in if work. Why don't my elif conditions work? [closed]

so this is my code :

import pandas as pd
import plotly.express as px
import os

def one():
    something = input('\nWhat Chart Do You Want To Do Today ?\nChoose One From These : (line/scatter/pie/bar) : ')

    if(something == 'line'):
        line()

    elif(something == 'scatter'):
        scatter()

    elif(something == 'pie'):
        pie()

    elif(something == 'bar'):
        bar()

    else:
        print('\nTHAT IS NOT A VALID INPUT DUMB')
        two()

def two():
    something = input('\nWhat Chart Do You Want To Do Today ?\nChoose One From These : (line/scatter/pie/bar) : ')

    if(something == 'line'):
        line()

    elif(something == 'scatter'):
        scatter()

    elif(something == 'pie'):
        pie()

    elif(something == 'bar'):
        bar()

    else:
        print('\nTHAT IS NOT A VALID INPUT DUMB')
        one()

def line():
    pathLine = input("\nType The Address Of Your File\n( Example : C:/Users/userName/Directory/FileName.csv ) : ")
    pathExists = os.path.exists(pathLine)
    if(pathExists == True):
        df = pd.read_csv(pathLine)
        x_axis = input("\nWhich Column Do You Want In The X Axis : ")
        y_axis = input("\nWhich Column Do You Want In The Y Axis : ")
        colorThing = input("\nWhich Column Do You Want The Colors To Be : ")
        titleThing = input("\nWhat Do You Want Your Chart's Title To Be : ")
        fig = px.line(df,x=x_axis, y=y_axis, color=colorThing, title=titleThing)
        print("\nYour Chart Should Open In A Few Moments...")
        fig.show()
    else:
        print('\nThat Is Not A Valid File Location')
        one()

def scatter():
    pathScatter = input("\nType The Address Of Your File\n( Example : C:/Users/userName/Directory/FileName.csv ) : ")
    pathExists = os.path.exists(pathScatter)
    if(pathExists == True):
        df = pd.read_csv(pathScatter)
        x_axis = input("\nWhich Column Do You Want In The X Axis : ")
        y_axis = input("\nWhich Column Do You Want In The Y Axis : ")
        colorThing = input("\nWhich Column Do You Want The Colors To Be : ")
        titleThing = input("\nWhat Do You Want Your Chart's Title To Be : ")
        fig = px.scatter(df,x=x_axis, y=y_axis, color=colorThing, title=titleThing)
        print("\nYour Chart Should Open In A Few Moments...")
        fig.show()
    else:
        print('\nThat Is Not A Valid File Location')
        one()

def pie():
    pathPie = input("\nType The Address Of Your File\n( Example : C:/Users/userName/Directory/FileName.csv ) : ")
    pathExists = os.path.exists(pathPie)
    if(pathExists == True):
        df = pd.read_csv(pathPie)
        colorThing = input("\nWhich Column Do You Want The Colors To Be : ")
        valuesThing = input("\nWhich Column Do You Want The Values To Be : ")
        titleThing = input("\nWhat Do You Want Your Chart's Title To Be : ")
        fig = px.pie(df,names=colorThing, values=valuesThing, color=colorThing, title=titleThing)
        print("\nYour Chart Should Open In A Few Moments...")
        fig.show()
    else:
        print('\nThat Is Not A Valid File Location')
        one()

def bar():
    pathBar = input("\nType The Address Of Your File\n( Example : C:/Users/userName/Directory/FileName.csv ) : ")
    pathExists = os.path.exists(pathBar)
    if(pathExists == True):
        df = pd.read_csv(pathBar)
        x_axis = input("\nWhich Column Do You Want In The X Axis : ")
        y_axis = input("\nWhich Column Do You Want In The Y Axis : ")
        colorThing = input("\nWhich Column Do You Want The Colors To Be : ")
        titleThing = input("\nWhat Do You Want Your Chart's Title To Be : ")
        fig = px.bar(df,x=x_axis, y=y_axis, color=colorThing, title=titleThing)
        print("\nYour Chart Should Open In A Few Moments...")
        fig.show()
    else:
        print('\nThat Is Not A Valid File Location')
        one()

one()

My goal was that anyone can create a chart easily or something like that... but the problem is that.. everytime i run it it only performs the line() function even if i type the input as bar/pie/scatter. can anyone explain what i have done wrong ?? (also ummmm i am new to python so please dont mock me)

(i am just writing this because stackoverflow says i have to add more details and i dont know what else to type so im just typing this to fill up the space dont mind this ok ?)

Aucun commentaire:

Enregistrer un commentaire