Adding items to shopping List Python









up vote
-3
down vote

favorite












I'm learning Python and I'm trying to make shopping List
where you can add items



first it will ask you to add the items if the shopping list is empty
it will be added automatically if not it will ask you where you would like
to put the item (index)



but also I'm trying to make the program exit in certain condition like DONE
or HELP or SHOW but even that i put a condition for that but it's not working can anyone help me with this



hope I explained enough



import os 
shopping_list =

# Function for clearing the screen
def clear_screen():
os.system("cls" if os.name == "nt" else "clear")

def show_help():
print("Enter 'Done' if you finish adding item n Enter 'Show' to show your items n Enter 'Help' toshow this help ")

# Function to show the items that you've entered to the list
def show_item():
clear_screen()
index = 1
for item in shopping_list:
print(" .".format(index,item))
index += 1

# Function to add items to the list
def add_to_list():
while True:
new_item = input("Please enter the item that you would like to add to your shopping list ")
if shopping_list and ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW")):
position = input("Where you would like to add to the list n press 'Enter' if you want to add to the end of the list".format(new_item))
position = abs(int(position))
shopping_list.insert(position - 1 , new_item)
show_item()
else:

if new_item.upper() == "DONE":
break
elif new_item.upper() == "SHOW":
show_item()
continue
elif new_item.upper() == "HELP":
show_help()
continue
else:
shopping_list.append(new_item)
show_item()

show_help()
add_to_list()









share|improve this question







New contributor




Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    -3
    down vote

    favorite












    I'm learning Python and I'm trying to make shopping List
    where you can add items



    first it will ask you to add the items if the shopping list is empty
    it will be added automatically if not it will ask you where you would like
    to put the item (index)



    but also I'm trying to make the program exit in certain condition like DONE
    or HELP or SHOW but even that i put a condition for that but it's not working can anyone help me with this



    hope I explained enough



    import os 
    shopping_list =

    # Function for clearing the screen
    def clear_screen():
    os.system("cls" if os.name == "nt" else "clear")

    def show_help():
    print("Enter 'Done' if you finish adding item n Enter 'Show' to show your items n Enter 'Help' toshow this help ")

    # Function to show the items that you've entered to the list
    def show_item():
    clear_screen()
    index = 1
    for item in shopping_list:
    print(" .".format(index,item))
    index += 1

    # Function to add items to the list
    def add_to_list():
    while True:
    new_item = input("Please enter the item that you would like to add to your shopping list ")
    if shopping_list and ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW")):
    position = input("Where you would like to add to the list n press 'Enter' if you want to add to the end of the list".format(new_item))
    position = abs(int(position))
    shopping_list.insert(position - 1 , new_item)
    show_item()
    else:

    if new_item.upper() == "DONE":
    break
    elif new_item.upper() == "SHOW":
    show_item()
    continue
    elif new_item.upper() == "HELP":
    show_help()
    continue
    else:
    shopping_list.append(new_item)
    show_item()

    show_help()
    add_to_list()









    share|improve this question







    New contributor




    Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      -3
      down vote

      favorite









      up vote
      -3
      down vote

      favorite











      I'm learning Python and I'm trying to make shopping List
      where you can add items



      first it will ask you to add the items if the shopping list is empty
      it will be added automatically if not it will ask you where you would like
      to put the item (index)



      but also I'm trying to make the program exit in certain condition like DONE
      or HELP or SHOW but even that i put a condition for that but it's not working can anyone help me with this



      hope I explained enough



      import os 
      shopping_list =

      # Function for clearing the screen
      def clear_screen():
      os.system("cls" if os.name == "nt" else "clear")

      def show_help():
      print("Enter 'Done' if you finish adding item n Enter 'Show' to show your items n Enter 'Help' toshow this help ")

      # Function to show the items that you've entered to the list
      def show_item():
      clear_screen()
      index = 1
      for item in shopping_list:
      print(" .".format(index,item))
      index += 1

      # Function to add items to the list
      def add_to_list():
      while True:
      new_item = input("Please enter the item that you would like to add to your shopping list ")
      if shopping_list and ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW")):
      position = input("Where you would like to add to the list n press 'Enter' if you want to add to the end of the list".format(new_item))
      position = abs(int(position))
      shopping_list.insert(position - 1 , new_item)
      show_item()
      else:

      if new_item.upper() == "DONE":
      break
      elif new_item.upper() == "SHOW":
      show_item()
      continue
      elif new_item.upper() == "HELP":
      show_help()
      continue
      else:
      shopping_list.append(new_item)
      show_item()

      show_help()
      add_to_list()









      share|improve this question







      New contributor




      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I'm learning Python and I'm trying to make shopping List
      where you can add items



      first it will ask you to add the items if the shopping list is empty
      it will be added automatically if not it will ask you where you would like
      to put the item (index)



      but also I'm trying to make the program exit in certain condition like DONE
      or HELP or SHOW but even that i put a condition for that but it's not working can anyone help me with this



      hope I explained enough



      import os 
      shopping_list =

      # Function for clearing the screen
      def clear_screen():
      os.system("cls" if os.name == "nt" else "clear")

      def show_help():
      print("Enter 'Done' if you finish adding item n Enter 'Show' to show your items n Enter 'Help' toshow this help ")

      # Function to show the items that you've entered to the list
      def show_item():
      clear_screen()
      index = 1
      for item in shopping_list:
      print(" .".format(index,item))
      index += 1

      # Function to add items to the list
      def add_to_list():
      while True:
      new_item = input("Please enter the item that you would like to add to your shopping list ")
      if shopping_list and ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW")):
      position = input("Where you would like to add to the list n press 'Enter' if you want to add to the end of the list".format(new_item))
      position = abs(int(position))
      shopping_list.insert(position - 1 , new_item)
      show_item()
      else:

      if new_item.upper() == "DONE":
      break
      elif new_item.upper() == "SHOW":
      show_item()
      continue
      elif new_item.upper() == "HELP":
      show_help()
      continue
      else:
      shopping_list.append(new_item)
      show_item()

      show_help()
      add_to_list()






      python






      share|improve this question







      New contributor




      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 9 at 12:49









      Khaled Khanfar

      1




      1




      New contributor




      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Khaled Khanfar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Welcome to stackoverflow. I think your logic statement is wrong, you need and instead of or. Right now all you need for the statement in the parentheses to be true, is that new_item.upper() is at least not one of those three words. It actually can't equate to False since two of the three are always true.



          ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))


          If you have for example done the first statement is False ,but the other two are True, adding up to True in or-Statements.



          >>> new_item = 'done'
          >>> print((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))
          True





          share|improve this answer




















          • Thanks Man thats worked for me really appreciate it :)
            – Khaled Khanfar
            Nov 9 at 13:07











          • Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
            – Bernhard
            Nov 9 at 13:22











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          Khaled Khanfar is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226016%2fadding-items-to-shopping-list-python%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Welcome to stackoverflow. I think your logic statement is wrong, you need and instead of or. Right now all you need for the statement in the parentheses to be true, is that new_item.upper() is at least not one of those three words. It actually can't equate to False since two of the three are always true.



          ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))


          If you have for example done the first statement is False ,but the other two are True, adding up to True in or-Statements.



          >>> new_item = 'done'
          >>> print((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))
          True





          share|improve this answer




















          • Thanks Man thats worked for me really appreciate it :)
            – Khaled Khanfar
            Nov 9 at 13:07











          • Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
            – Bernhard
            Nov 9 at 13:22















          up vote
          0
          down vote













          Welcome to stackoverflow. I think your logic statement is wrong, you need and instead of or. Right now all you need for the statement in the parentheses to be true, is that new_item.upper() is at least not one of those three words. It actually can't equate to False since two of the three are always true.



          ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))


          If you have for example done the first statement is False ,but the other two are True, adding up to True in or-Statements.



          >>> new_item = 'done'
          >>> print((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))
          True





          share|improve this answer




















          • Thanks Man thats worked for me really appreciate it :)
            – Khaled Khanfar
            Nov 9 at 13:07











          • Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
            – Bernhard
            Nov 9 at 13:22













          up vote
          0
          down vote










          up vote
          0
          down vote









          Welcome to stackoverflow. I think your logic statement is wrong, you need and instead of or. Right now all you need for the statement in the parentheses to be true, is that new_item.upper() is at least not one of those three words. It actually can't equate to False since two of the three are always true.



          ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))


          If you have for example done the first statement is False ,but the other two are True, adding up to True in or-Statements.



          >>> new_item = 'done'
          >>> print((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))
          True





          share|improve this answer












          Welcome to stackoverflow. I think your logic statement is wrong, you need and instead of or. Right now all you need for the statement in the parentheses to be true, is that new_item.upper() is at least not one of those three words. It actually can't equate to False since two of the three are always true.



          ((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))


          If you have for example done the first statement is False ,but the other two are True, adding up to True in or-Statements.



          >>> new_item = 'done'
          >>> print((new_item.upper() != "DONE") or (new_item.upper() != "HELP") or (new_item.upper() != "SHOW"))
          True






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 9 at 12:53









          Bernhard

          815115




          815115











          • Thanks Man thats worked for me really appreciate it :)
            – Khaled Khanfar
            Nov 9 at 13:07











          • Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
            – Bernhard
            Nov 9 at 13:22

















          • Thanks Man thats worked for me really appreciate it :)
            – Khaled Khanfar
            Nov 9 at 13:07











          • Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
            – Bernhard
            Nov 9 at 13:22
















          Thanks Man thats worked for me really appreciate it :)
          – Khaled Khanfar
          Nov 9 at 13:07





          Thanks Man thats worked for me really appreciate it :)
          – Khaled Khanfar
          Nov 9 at 13:07













          Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
          – Bernhard
          Nov 9 at 13:22





          Then you might wanna mark the answer as accepted, so it's clear that the question is closed, so to speak. Have fun!
          – Bernhard
          Nov 9 at 13:22











          Khaled Khanfar is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          Khaled Khanfar is a new contributor. Be nice, and check out our Code of Conduct.












          Khaled Khanfar is a new contributor. Be nice, and check out our Code of Conduct.











          Khaled Khanfar is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53226016%2fadding-items-to-shopping-list-python%23new-answer', 'question_page');

          );

          Post as a guest














































































          Popular posts from this blog

          Darth Vader #20

          How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

          Ondo