double index challenge (will my code fail in any circumstance?)
the code i wrote:

def double\_index(lst, index):

try:

return lst[0:index] + [lst[index]*2] + lst[index + 1:]

except indexerror:

return lst

code academy solution:

def double\_index(lst, index):

if index >= len(lst):

return lst

else:

new\_lst = lst[0:index]

new\_lst.append(lst…
according to python idiomatic, its better to ask for forgiveness (except) then for permission (if). which would make your solution a better fit

however, i disagree with the slicing used in both solutions. you have the index, so its easy to update an element at an index:

the\_list[index] = 'new valu…
[image] wbriggs90:

for (int i = 0; i <= num\_leds; i++) {

this writes num\_leds+1 pixels, probably not what you wanted.

as the index starts with 0, the highest correct index would be num\_leds-1, not num\_leds. What problem are you facing? Post the error that you get.  

Also please edit your first post by aligning the code properly and wrap [code] tag so that it is easily understandable for us to analyze. for your insertion and bubble sort, you are returning the comparison value, but you are not assinging it to anything when that value is returned. In your main



```
insertionSort(copy_integers_1);
```

Change that to:



```
int compInsertion = 0;
...
compInsertion = insertionSort(copy_integers_1);
```

and do the same with your bubble sort.



It actually would work the way it is, but the second time you call your functions (in your cout statements in main) the arrays are already sorted.



As for your error, try this



```
int *L = new int[Left_Size];
int *R = new int[Right_Size];
```

Also, you probably don't need to declare Left\_Size or Right\_Size as const. [@cssc](/u/cssc), another option would be to take the regex way.

first, it finds the index of the 5th pipe.

then, it takes the substring until that index.

give this a try:

inputstr.substring(0, regex.matches(inputstr, "\|")(4).index + 1) hi stuti, 
index can be used with lists, not tables. 
if a variable is used as an index, it is put in the square brackets without the dollar sign and curly brackets, i.e. ${data\_list[item\_index]}. 
you can read more about using indexes with lists in the knowledge base: [https://kb.workfusion.com/disp…](https://kb.workfusion.com/display/rpae/recorder+variables#recordervariables-usingindexeswithlists) Your function works, but both the IF and the ELSE return an alert message that says its invalid.  

The first part - the IF - should return in the alert box "Valid SSN"  

I am assuming your input should be like this 123-45-1234


but do you need to tell the user the input is valid? Surely the alert should only be displayed if the input is invalid? So the if should return nothing. imho c = input()  

t = len(c)  

temp = ""  

for i in range(0,len(c)):  

    if t<3:  

        break  

    else:  

        if i in (0,1,t-2,t-1):  

            temp = temp+c[i]  

        else:  

            continue  

print(temp) How you do this will depend on a number of factors: since you haven't tried to explain in any detail, I'll assume you know nothing, and just give you the basics.  

  

The easiest way to do this is to read the text file into a single string, and then use the .NET framework to find the match:  


```
Dim text As String = File.ReadAllText("D:\Temp\MyFile.txt")
Dim index As Integer = text.IndexOf("hello")
If index >= 0 Then
   ' String is in file, starting at character "index"
End If
```
  

There are other ways, but that is pretty much the simplest. Please see: [How do I schedule a task to update indexes?](https://qa.mythicsoft.com/14733/how-do-i-schedule-a-task-to-update-indexes?show=14733#q14733) howdy and welcome to the forum!

take a closer look at the comment on line 13…it suggests using a different method

you are incrementing enemyindex, but not quite in the correct place…it should be the final statement in your while(enemyindex…) loop

like item 1, don’t forget the instructions in the c…