Ich bin neu in Python. Hier ist meine Datei:Python-Syntaxfehler deklariert Variable
contiguous.py:
def fillArray(len, val):
var arr = [], i
for i = 0; i < len; i++:
arr.append(val)
return arr
Ich versuche auszuführen:
$ python contiguous.py
File "contiguous.py", line 2
var arr = [], i
^
SyntaxError: invalid syntax
$ python -V
Python 3.6.0
Warum der Fehler? Was vermisse ich?
Weil das nicht python ist ... – TemporalWolf
Nun, da Python keine Variablendeklarationen hat, würde ich hoffen, dass Sie einen Fehler bekommen ... –
Ernsthaft, werfen Sie einen Blick auf das offizielle [Python Tutorial] (https : //docs.python.org/3/tutorial/). Es ist sehr gut, besonders wenn Sie bereits Programmiererfahrung haben. –