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:

Charlie Clark
19.7k4 gold badges56 silver badges64 bronze badges
asked Dec 26, 2019 at 18:50

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) 
answered Dec 26, 2019 at 18:53
1
  • Thanks! It was the answer I was looking for, Commented Dec 26, 2019 at 19:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.