Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
First piece of code
#3
What do you mean by:
Quote:The code loads so I can test the instance but it doesn't produce an answer?
The code produces the answer: "Here are some tips on how to reduce the environmental impact of your event:" Granted that is not a useful answer, but your program cannot produce any other answer because it only has one.

Let's start with "What is the program supposed to do?" This is obviously a homework assignment. You should post the instructions along with the code. As is, I don't know what code you wrote (probably new_func()) or what the code is supposed to do.

The database is empty.
# Create a database to store the questions and answers
database = {}
You never put anything in database, so it never finds any answers.

What are you doing here?
def new_func():
    return "Here are some tips on how to reduce the environmental impact of your event:\n"
 
answers = [new_func().strip()]
Reply


Messages In This Thread
First piece of code - by Bearwulf - Aug-02-2023, 02:49 AM
RE: First piece of code - by menator01 - Aug-02-2023, 03:54 AM
RE: First piece of code - by deanhystad - Aug-02-2023, 04:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  An unexplainable error in .format statement - but only in a larger piece of code? ToniE 4 749 Sep-05-2023, 12:50 PM
Last Post: ToniE
  Understanding a piece of code Michael1 4 1,463 Jan-20-2022, 07:14 PM
Last Post: Michael1
  How to make this piece concise leoahum 0 1,361 Sep-23-2021, 09:23 PM
Last Post: leoahum
  .maketrans() - a piece of code which needs some explanation InputOutput007 5 3,048 Jan-28-2021, 05:05 PM
Last Post: buran
  I am a newbie.Help me with this simple piece of code feynarun 3 2,865 Jan-08-2020, 12:40 PM
Last Post: perfringo
  How can I improve this piece of code? aquerci 3 2,241 Nov-17-2019, 10:57 AM
Last Post: Gribouillis
  Am i doing something wrong with this piece of code pythoneer 3 2,738 Mar-02-2018, 08:50 PM
Last Post: JustaNoOb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020