In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of December 7th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #08 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
Tyrion Lannister, known for his wit and love of wine, was handling some important data stored in a CSV file. However, after one too many goblets of wine, he mistakenly mixed up the columns while organizing the file. Now, he needs to swap two specific columns in the CSV file to correct his mistake before presenting it to the Small Council.
Write a function csv_change(text, a, b) that given a string text with values separated by commas, returns a new text that corresponds to the exact same text but with the values in columns a and b swapped. The columns indices start at 1 and a and b will always be valid and distinct columns.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ |text| ≤ 200 | length of text |
You can also be assured that the values will not contain commas, so the only commas present in the text will be separating different columns.
Example Function Calls | Example Output |
print(csv_change("attack,the,starks,dawn,at", 4, 5)) print(csv_change("reason,is,more,powerful,than,love", 1, 6)) print(csv_change("That's, what, I, do, I, drink, and, I, know, things", 6, 4)) |
attack,the,starks,at,dawn love,is,more,powerful,than,reason That's, what, I, drink, I, do, and, I, know, things |