Tuesday 15 January 2013

python - Writing to text file error -


Hi, I am working on a program to store some files in a text document that can be reloaded when necessary. The code below is the beginning, though, when I think that I defined it as the name of the text file, then when I receive a trace back error, saying "I did not define the recipe_top word" is run please Tell me what I have done wrong

  import sys opt = 0 def preference (1): print ("work") def (2) choice (): Recipe_Name = input ("please enter the recipe name:") Recipe_List = open (recipe_title) TCTT, "W") (component == "end" or "end" or "EDD" or "end" or "end" or "end" or "end" or "android" "nd" or " ANd "or" NND "or" END "): recipe.written (recipe_chitten)  

Recipe_title.txt is your file name and there is no variable so you add quote

  Recipe_List = open ('recipe_title.txt', 'w ')  

Or if the bankruptcy title is actually a variable:

  Recipe_List = open (' {} .txt'format (recipe_title), "w ") Now you can open brocolli.txt for example  

General feedback about your code:

  • Character names do not contain uppercase letters needed. It should only be used for class names.
  • On checking that all combinations of 'end' can be written on if ingredient.lower () == "end":

No comments:

Post a Comment