Python 3:

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Python 3:

Post by answerhappygod »

Python 3:
Python 3 1
Python 3 1 (14.81 KiB) Viewed 10 times
I've got desc = ['(4,1);(1,4)', '(2,3);(3,2)', '(4,2);(2,4); (1,3);(3,1)', '(1,2); (2,1); (4,3); (3,4)*] and I want the output to be [[(4, 1), (1, 4)], [(2, 3), (3, 2)], [(4, 2), (2, 4), (1, 3), (3, 1)], [(1, 2), (2, 1), (4, 3), (3, 4)]]. So far I've tried: for x in range (len (desc)): desc [x] = desc [x].split(';') for y in range(len (desc [x])): desc [x][y] = eval(desc [x][y]) but there is a syntax error saying 'unexpected EOF while parsing'. How do I fix my code?
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply