Question: Write a function called get_filename(names_list, index) that takes a list of names and an index as parameters and returns the filename of the colour palette
Write a function called get_filename(names_list, index) that takes a list of names and an index as parameters and returns the filename of the colour palette and the filename of the pattern based on the parameter index. The function should return the result as a tuple. The filename of the colour palette is a name in the list with "_palette.txt" at the end, and the filename of the pattern is simply the name and ".txt" at the end.
For example:
| Test | Result |
|---|---|
names_list = ['steve', 'pig', 'zombie', 'skeleton', 'creeper1', 'creeper2'] print(get_filename(names_list, 0)) print(get_filename(names_list, 5)) | ('steve_palette.txt', 'steve.txt') ('creeper2_palette.txt', 'creeper2.txt') |
names_list = ['steve', 'pig', 'zombie', 'skeleton', 'creeper1', 'creeper2'] print(get_filename(names_list, 3)) print(get_filename(names_list, 2)) | ('skeleton_palette.txt', 'skeleton.txt') ('zombie_palette.txt', 'zombie.txt') |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
