Python Forum
apendng to a list within a class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
apendng to a list within a class
#2
Your input() method asks for a fruit (line 10).

On line 11, you're comparing the input function against a single space. This will never be true, so execution goes to line 14 and the method exits without doing anything.

I assume you meant to compare it to inp instead of input. If you did that and the fruit you entered was a single space, it would add that space it to the list (lines 11-12).
If it were any other string, nothing is done and fruit_list remains the same.

Even if you had modified the list, nothing in this script will show the contents. You'd need to print the attribute (or do something with it) to see the results.
Reply


Messages In This Thread
apendng to a list within a class - by gr3yali3n - Feb-15-2021, 11:23 PM
RE: apendng to a list within a class - by bowlofred - Feb-16-2021, 12:04 AM
RE: apendng to a list within a class - by gr3yali3n - Feb-16-2021, 02:38 AM
RE: apendng to a list within a class - by bowlofred - Feb-16-2021, 03:34 AM
RE: apendng to a list within a class - by buran - Feb-16-2021, 06:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to read module/class from list of strings? popular_dog 1 553 Oct-04-2023, 03:08 PM
Last Post: deanhystad
  Class-Aggregation and creating a list/dictionary IoannisDem 1 1,991 Oct-03-2021, 05:16 PM
Last Post: Yoriz
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 2,402 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92
  Appending a list in a class from a callback function snizbatch 5 3,845 Sep-01-2019, 06:27 AM
Last Post: snizbatch
  how to add class instance attributes from list 999masks 2 2,795 Jul-22-2019, 07:59 AM
Last Post: 999masks
  Build class to make a Smart list - trying icm63 7 3,586 Mar-28-2019, 08:53 PM
Last Post: icm63
  why my method doesn't find my List in the same class? Scorpio 2 2,434 Jan-31-2019, 05:21 PM
Last Post: Scorpio
  Generate list in class P13N 7 4,474 Dec-28-2018, 10:08 PM
Last Post: P13N
  How to check if class instance exists in a list of class instance objects? sonicblind 23 20,774 May-27-2018, 05:44 AM
Last Post: buran
  Create class instances from list of strings pythonck 1 3,680 Sep-18-2017, 06:13 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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