Oct-16-2016, 10:39 AM
Hello,
I would like to know how to get rid of brackets within a list. Ex. ['1', 'r', (2, '5')]. The round brackets inside this list, I would like to get rid of.
Here is the code in question:
I would like to eventually get this to print off an index with no brackets what so ever. But I have seen a tutorial on how to do that in the "list basic" thread. Unfortunately, the procedure will print with the round brackets included for the above code.
Look forward to your responses.
Thank you,
A3G
I would like to know how to get rid of brackets within a list. Ex. ['1', 'r', (2, '5')]. The round brackets inside this list, I would like to get rid of.
Here is the code in question:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#function for requesting numerical mark --> ask if this function is necessary because computeGrade prompts for both the mark and gives the letter grade. def getMark(): mark = int ( input ( "What is your mark? (eg. 50) " )) return mark #function for letter grades def computeGrade(): #must get the grade from function getMark() or it will keep asking you for inputs each step of the way, when entering getMark in as a function gr = getMark() if gr < 50 : g = "F" print (g) elif gr > 49 and gr < 55 : g = "D" print (g) elif gr > 54 and gr < 65 : g = "C" print (g) elif gr > 64 and gr < 80 : g = "B" print (g) elif gr > = 80 : g = "A" print (g) else : #how to make it so if they enter anything other than numerical values it gives you an error message? print ( "Invalid input, please enter your numerical grade such as 40, 80, or 90" ) return (gr, g) #making the list using previous functions def student(): #studlist = [getLastname(), getFirstname(), getMark(), computeGrade()] studlist = [getLastname(), getFirstname(), computeGrade()] return studlist print (student()) |
Look forward to your responses.
Thank you,
A3G