mercredi 23 juin 2021

How If and Else works inside a For loop

I know this is simple, but I just can not understand how if and else statement works inside a for loop. This is the code I`m trying:

count = IN[0]
value = IN[1]

out = []

for i in range (count):
    if i==7:    
    out.insert(i,'report')
    else:
    out.insert(i,value)
    
OUT = out

I`m getting the error message: "expected an indented block"

Basically, I need:

  1. To create a list of size 'count';
  2. Add 'value' on every index, but on index 7 I need it to be string 'report'

Aucun commentaire:

Enregistrer un commentaire