Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Aaron Peter
Aaron Peter
1,498 Points

i need help : How do you extract certain type of information from a tuple to form it into a list?

heres my code to input data into the tuple within a list. i want to create a list of full time works only pdata_list = [] y = 0 while y!='x': print ('a. Add a new employee record') print ('b. Display all employees') print ('c. Search for employee record (view details)') print ('d. Delete an employee record') print ('e. Show all full-time employees') print ('f. Show all part-time employees') print ('x. Exit') print ('Choose an option (a to f) or x to Exit') y = input('Enter a letter: ')

if y == 'a':
    first_name = str(input("Enter your First Name: "))
    Surname = str(input("Enter your Surname: "))
    Job_title = str(input("Enter your Job Title: "))
    Fulltime = str(input( "Are you Full Time (Yes or No): "))
    Hourly_rate = float(input( "Enter your Hourly rate: "))
    Hperweek = float(input( " Enter your hours per week: "))

    pdata_list.append((Surname,first_name,Job_title,Fulltime,Hourly_rate,Hperweek),)

if y == 'e':
    for i in pdata_list:
         if Fulltime == 'Yes' or 'yes':
            print ()
            print ('First Name: ',i[1])
            print ('Surname: ',i[0])
            print ('Job Title: ',i[2])
            print ('Full Time: ',i[3])
            print ('Hourly Rate:£',i[4])
            print ('Hours per Week: ',i[5])

here my code to find the full time works only and to display them ^^^^^

1 Answer

Steven Parker
Steven Parker
231,269 Points

When examining the tuple, the status is no longer in the "Fulltime" variable. Also, you can only combine complete comparisons with "or", but here you could use a case conversion and do just one test:

             if i[3].lower() == 'yes':