0

I`am trying to extract some data from a sheet in excel 'recursos is the name of the page', I would like to not use the current for cycle any ideas?

celdas3=recursos['AN8':str(rsearch)+str(max_row)]   

for c1,c2,c3,c4,c5,c6,c7,c8,c9,c10 in celdas3:                
    var_3=[c1.value,c2.value,c3.value,c4.value,c5.value,c6.value,c7.value,c8.value,c9.value,c10.value]
    ex3.append(var_3)
    print(ex3)   

And I would like to instead of use c1,c2,c3, etc use a variable. celdas3 is:

1 Answer 1

3

You don't have to unpack the list in the for loop:

for c in celdas3:                
    var_3 = [c1.value for c1 in c]
    ex3.append(var_3)
    print(ex3)   
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It was the answer I was looking for,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.