The Student Room Group

What does this code do python

for line in file: # for loop
f = line.split() # turns line separated by whitespace into a list

(firstName, lastName, score1, score2, score3) = [t(s) for t,s in zip((str,str,int,int,int), f)]#zip #extracting fields into variable with the correct type. tuple
Reply 1
I don't know python but judging by the comments i can say it Splits a sentence like this one into a list of words and numbers and then takes those words or numbers and inputs them into a variable such as an integer or string.
Are you learning to code?
Original post by Johns123
I don't know python but judging by the comments i can say it Splits a sentence like this one into a list of words and numbers and then takes those words or numbers and inputs them into a variable such as an integer or string.
Are you learning to code?


Oh thanks,
It's for my report for computing
Reply 3
Oh so you actually got to learn a decent language, they made us do visual basic :C
Original post by adnanuddin233
Oh thanks,
It's for my report for computing
Original post by Johns123
Oh so you actually got to learn a decent language, they made us do visual basic :C


:rofl: VB is a monster

Quick Reply

Latest