Need help with for loops | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Need help with for loops

The question is Fill in the blanks to iterate over the list using a for loop and print its values Here's what I have so far: list = [1,2,3] for var in list: print ( ) (I need to fill in the blank brackets above, but I am not sure what to put there).

11th Apr 2018, 3:14 PM
e.than_w
e.than_w - avatar
4 Respostas
+ 5
list=[1,2,3] for var in list: print(var) use indentation after for loop. another idea: print(var,end=' ')
11th Apr 2018, 3:53 PM
Maninder $ingh
Maninder $ingh - avatar
+ 1
Loop is basically a repeated form of a task... If you want to input on šŸ”³ something many times you should use loop by giving range according to your need... And for printing, do the same but apply output bject or function....
11th Apr 2018, 3:37 PM
ARIF ANSARI
ARIF ANSARI - avatar
0
the line "for var in list" translates to: for every var(variable) in the list. in the code, you refer to each object in the list as "var". soo if you want to display all of the objects in the list, you type:"for var in list: print (var)". sorry if i didn't explain well enough.
11th Apr 2018, 3:42 PM
[Adenosine]
[Adenosine] - avatar
0
list=[1,2,3] for var in list: print(var) # Todo lo que se quiera ejecutar dentro del loop debe ir indentado. Imprime los valores de la lista en lĆ­neas separadas, a medida que va leyendo la lista. print(var,end=' '). #Imprime los valores seguidos en la misma lĆ­nea. print(f"Los valores son {Var}") Espero haber ayudado.
15th Apr 2018, 2:16 PM
Luis Gonzalez
Luis Gonzalez - avatar