Hi i have a question regarding the understand code:
grades = [float(a) for a in list[1].split(' ')]
I get the next error: ValueError: could not convert string to float: '6.7\nFrans'
'6.7\nFrans' is from the input file.txt
Split using both metrics with the built in library re
:
import re
grades = [float(a) for a in re.split(' |\n',list[1])]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.