This simple piece of code wont work for me! where have i gone wrong? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

This simple piece of code wont work for me! where have i gone wrong?

this simple piece of code wont work for me: start = [range(0, 40)] for word in start: print(word) print(">End<") Please help! thanks!

2nd Jul 2018, 2:35 PM
Dotan Kryspynator
Dotan Kryspynator - avatar
4 Answers
+ 3
You can also just omit the brackets, then start contains the range-object. start = range(0, 40) for word in start: print(word) print(">End<")
2nd Jul 2018, 2:43 PM
Matthias
Matthias - avatar
+ 4
start = range(0, 40) Since range returns a list by default there is no need for the brackets.
2nd Jul 2018, 2:42 PM
Kevin Eldurson
Kevin Eldurson - avatar
+ 4
2nd Jul 2018, 2:48 PM
Dotan Kryspynator
Dotan Kryspynator - avatar
+ 1
I have 2 simple solutions: #By list comprehension: start = [i for i in range(0, 40)] for word in start: print(word) print(">End<") #By list function: start = list(range(0, 40)) for word in start: print(word) print(">End<")
2nd Jul 2018, 2:45 PM
Seb TheS
Seb TheS - avatar