Python Forum
how to remove brackets within a list
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to remove brackets within a list
#6
Thank you for the prompt reply.

But when I enter this in:

from itertools import chain
my_list = [student()]
def flatten(listOfLists):
    return chain.from_iterable(listOfLists)
my_flattened_list = list(flatten(my_list))
print(my_flattened_list)
It returns -->['lastname', 'firstname', (mark, 'letter grade)]

sorry did not see your second post Yoriz.

That piece of code is much easier to understand and it works... but it prompts me for my mark before asking for my last name and first name.... how do i make it so the order asks for last name and first name then mark and gives grade?

def student():
    #studlist = [getLastname(), getFirstname(), getMark(), computeGrade()]
    gr, g = computeGrade()
    studlist = [getLastname(), getFirstname(), gr, g]
    return studlist
returns the proper list that i was after! but need the correct order of question.
Reply


Messages In This Thread
how to remove brackets within a list - by A3G - Oct-16-2016, 10:39 AM
RE: how to remove brackets within a list - by wavic - Oct-16-2016, 11:00 AM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 11:05 AM
RE: how to remove brackets within a list - by wavic - Oct-16-2016, 11:10 AM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 11:16 AM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 11:20 AM
RE: how to remove brackets within a list - by wavic - Oct-16-2016, 11:25 AM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 11:31 AM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 11:31 AM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 11:39 AM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 11:44 AM
RE: how to remove brackets within a list - by wavic - Oct-16-2016, 11:44 AM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 12:16 PM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 12:42 PM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 01:11 PM
RE: how to remove brackets within a list - by Yoriz - Oct-16-2016, 01:24 PM
RE: how to remove brackets within a list - by A3G - Oct-16-2016, 01:39 PM
RE: how to remove brackets within a list - by wavic - Oct-16-2016, 02:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove duplicates from dicts with list values wardancer84 27 888 May-27-2024, 04:54 PM
Last Post: wardancer84
  unable to remove all elements from list based on a condition sg_python 3 587 Jan-27-2024, 04:03 PM
Last Post: deanhystad
  Remove numbers from a list menator01 4 1,498 Nov-13-2022, 01:27 AM
Last Post: menator01
  [SOLVED] [BeautifulSoup] Why does it turn inserted string's brackets into </>? Winfried 0 1,607 Sep-03-2022, 11:21 PM
Last Post: Winfried
  Reading list items without brackets and quotes jesse68 6 4,829 Jan-14-2022, 07:07 PM
Last Post: jesse68
  Remove empty keys in a python list python_student 7 3,252 Jan-12-2022, 10:23 PM
Last Post: python_student
  Data pulled from SQL comes in brackets nickzsche 3 2,832 Jan-04-2022, 03:39 PM
Last Post: ibreeden
  For Loop and Use of Brackets to Modify Dictionary in Tic-Tac-Toe Game new_coder_231013 7 2,380 Dec-28-2021, 11:32 AM
Last Post: new_coder_231013
  Remove an item from a list contained in another item in python CompleteNewb 19 6,000 Nov-11-2021, 06:43 AM
Last Post: Gribouillis
  Getting a certain value from inside brackets. LeoT 5 3,143 Mar-01-2021, 03:34 PM
Last Post: buran

Forum Jump:

User Panel Messages

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