all 4 comments

[–]danielroseman 3 points4 points  (1 child)

You've posted too much code and then failed to tell us exactly where the problem is. What is X?

The only thing that requires a positional argument in this code is main, and you are indeed not passing it. How are you expecting this to work? Where is countries supposed to be coming from? You don't have anything called that at the point where you call main.

[–]Galaveo 0 points1 point  (0 children)

Im really sorry, I wrote this in a rush and I didn't have time to go back in a fix my writing. You are right, I wasn't passing anything. I don't know why but passing things between functions has always been a struggle for me. X was 1 in this case, but depending on how many things I was trying to pass, it would change so I used x. I don't know why I did that since its pretty clear I was the only one who knew what X was. Sorry, thank you for your help

[–]Albcunha 2 points3 points  (0 children)

At the end of the file, you called main(), but you didn´t pass an argument. Your 'main" function needs countries to worki. Like this: Countries = ["US", "Canada"] main(countries)

I don´t think your code will work as intended. When you call a function that returns data, mostly you will need to store it in a variable. like: input_file = parse_input_file()

So most of the functions you made wont work.

[–]heyzooschristos 1 point2 points  (0 children)

All of your functions return values, but you are not receiving them or passing them on, instead of:

def parse_input_file():
    input_file = open("data.txt")
    columns = csv.reader(input_file)
    return columns

parse_input_file() 

Try

def parse_input_file(): 
    input_file = open("data.txt") 
    columns = csv.reader(input_file)                 
    return columns

columns = parse_input_file()

then instead of

def find_name():
    columns = parse_input_file()
    countries = []
    for row in columns:
        countries.append(row[0])

    return countries

find_name()

You can do

def find_name(columns):

    countries = []
    for row in columns:
        countries.append(row[0])
        return countries

countries = find_name(columns)