Python Forum
user input to select and print data from another class python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
user input to select and print data from another class python
#1
This is a snippet of my playercharacter class, specifically the inventory which later calls Weapon which is another class with a list of weapons and individual stats. I am attempting to have user input select one of the weapons from the inventory specifically, then print out the details of the weapon, but am having difficulties coming up with the logic for it. Can anyone assist me in doing so?

def getinventory(self): 
    for object in self.inventory:
        print object.getname()

        choice = raw_input("""Do you wish to look at any of the items?
""")
        if choice == 'yes' or choice == 'y':
            choice = raw_input("""Which item?
""")
            if choice == object.name in self.inventory:
                object.__str__(choice)
Reply


Messages In This Thread
user input to select and print data from another class python - by TyTheChosenOne - Aug-30-2018, 04:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a Python solution to select unique frames from a video? rownong 1 784 Feb-02-2025, 09:56 AM
Last Post: Larz60+
  How to revert back to a previous line from user input Sharkenn64u 2 1,287 Dec-28-2024, 08:02 AM
Last Post: Pedroski55
  I think I need to delete input data because returning to start fails thelad 2 1,248 Sep-24-2024, 10:12 AM
Last Post: thelad
  User input with while loops chizzy101010 2 7,234 Aug-25-2024, 06:00 PM
Last Post: chizzy101010
  XML minidom "Pretty Print" Lost Data marksy95 2 1,453 Jun-15-2024, 11:09 AM
Last Post: Larz60+
  How to Randomly Print a Quote From a Text File When User Types a Command on Main Menu BillKochman 12 4,916 Apr-12-2024, 11:51 AM
Last Post: deanhystad
  Help with to check an Input list data with a data read from an external source sacharyya 3 1,908 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  manually input data jpatierno 0 855 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Input network device connection info from data file edroche3rd 6 3,045 Oct-12-2023, 02:18 AM
Last Post: edroche3rd
  WHILE LOOP NOT RETURNING USER INPUT AFTER ZerroDivisionError! HELP! ayodele_martins1 7 2,767 Oct-01-2023, 07:36 PM
Last Post: ayodele_martins1

Forum Jump:

User Panel Messages

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