+ 7
python error
Hey sorry I have kinda zero python knowledge...but i know java.... can anyone explain this error in python? can anyone help me fix it for me please? ________________________________________________________________ def jumble(prices): s = len(prices) newPrices = [None]*s for x in prices: s = s - 1 newPrices[s] = x return newPrices _____________________________________________________ thank you! https://code.sololearn.com/c2St5D74N8fk/?ref=app
5 Réponses
+ 8
The errors come from tabulations (tabulations are very important in Python, they replace the "{}" of many other languages). If we put the tabulations in the right places, we have:
def jumble(prices):
s = len(prices)
newPrices = [None]*s
for x in prices:
s = s - 1
newPrices[s] = x
return newPrices
list=[1,9,3,7]
print(jumble(list))
This code is like:
list=[1,9,3,7]
print(list[::-1])
+ 7
And also the function argument must be a list, because int have not the len() attribute
+ 5
Mirielle thanks!