I'm Stuck - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: I'm Stuck (/thread-2123.html) Pages:
1
2
|
I'm Stuck - 13owatts - Feb-20-2017 Hi, I was wondering if anyone could help me with this code. When I enter any word (Thing, in this example) it comes up with this error:
This is my code, and I honestly have no idea why this is happening.favMeal = [] header = ['Starter','Main','Dessert','Drink'] favMeal.append(header) print(favMeal) def get_string_inputs(p): strData = input("Please enter {0}: ".format(p)) return strData def add_data_rows(): meal_details = [ ] starter_c = get_string_inputs("your starter dish ") meal_details.append(starter_c) main_c = get_string_inputs("your main course ") meal_details.append(main_c) dessert_c = get_string_inputs("your dessert course ") meal_details.append(dessert_c) drink = get_string_inputs("your drink ") meal_details.append(drink) return meal_details def main(): favMeal= [ ] header = ['Starter','Main', 'Dessert', 'Drink'] favMeal.append(header) meal_details = add_data_rows() favMea.append(meal_details) for a,b,c,d in favMeal: print('{0:<16} {1:<16} {2:<16} {3:<16}'.format(a,b,c,d)) main()Any help would be greatly appreciated. RE: I'm Stuck - metulburr - Feb-20-2017 is this homework or an assignment? RE: I'm Stuck - 13owatts - Feb-20-2017 It is a homework we were given to complete for Thursday, and add a new section to it. We had to follow the sheet we were given. Even though I have typed it out exactly as printed, it comes up with an error. RE: I'm Stuck - wavic - Feb-20-2017 Typo! favMea.append(meal_details) # here <<< for a,b,c,d in favMeal: print('{0:<16} {1:<16} {2:<16} {3:<16}'.format(a,b,c,d))Your code is a bit messy RE: I'm Stuck - 13owatts - Feb-20-2017 I've corrected the spelling, but it still comes up with the same error. I keep looking through it, I just can't see what'd be wrong with it. RE: I'm Stuck - Larz60+ - Feb-20-2017 I get a completely different error (also a mispelling) change: favMea.append(meal_details)To: favMeal.append(meal_details) RE: I'm Stuck - 13owatts - Feb-20-2017 I've changed the error, twas pointed out previously, but it still comes up with the same error. RE: I'm Stuck - wavic - Feb-20-2017 How do you run the script? RE: I'm Stuck - 13owatts - Feb-20-2017 I use repl.it to write and execute my code, it's a free online Python platform. RE: I'm Stuck - wavic - Feb-20-2017 If you can, run it on Python 3 |