Dec-07-2019, 05:03 PM
Your for loop is going to high. Note that len(num) is 15, and remember that the index of the first item is 0. So the index of the last item is 14. You range will go from 0 to 15 (one short of len(num) + 1, or just len(num)). So at the end you are trying to get num[15], which is out of range, as the error notes.
You can get this with simple slicing:
You can get this with simple slicing:
output = num[:1] + num[-5:]
.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures