samedi 29 avril 2017

How to call the next line during enumerate when using if-and-if statement

I am working on the code below where AnalyteName_user_input is a list of strings as seen in the image below.

AnalyteName_user_input

Occasionally there is an instance where the value of index seven is 'W' rather than 'W2'. The current goal is to create a new list which would be AnalyteRatio_user_input. This would contain the values of a ratio evaluation between float values from the MeanResponse_list list. I believe the current issue lies in line 3 where I am attempting to use an if-in-and-if-in statement. I believe the issue is that I am trying to call the next line in the enumeration but line+1 is the 'W' value from the AnalyteName_user_input list. How would I remedy this to call the next line in the list rather than the string and then adding some int value?

AnalyteRatio_user_input = []
for i, line in enumerate(AnalyteName_user_input):
    if 'W' in line and 'W2' in line+1: # need a way to define the next line. Unsure about this.
    AnalyteRatio_user_input.append(MeanResponse_list[i]/MeanResponse_list[i+5])
    AnalyteRatio_user_input.append(MeanResponse_list[i+1]/MeanResponse_list[i+5])
    AnalyteRatio_user_input.append(MeanResponse_list[i+2]/MeanResponse_list[i+5])
    AnalyteRatio_user_input.append(MeanResponse_list[i+3]/MeanResponse_list[i+5])
    AnalyteRatio_user_input.append(MeanResponse_list[i+4]/MeanResponse_list[i+5])
    AnalyteRatio_user_input.append(MeanResponse_list[i+5]/MeanResponse_list[i+5])
else:
    AnalyteRatio_user_input.append('N/A') 

Aucun commentaire:

Enregistrer un commentaire