-3

This is the error i get:

File "<stdin>", line 1
& "C:/Users/myName/AppData/Local/Microsoft/WindowsApps/python3.9.exe" "c:/xampp/htdocs/SD/UAS Prak/No1.py"
^

SyntaxError: invalid syntax


And here is my full code:
my code in VS code my code is VS code2

def proses(start,end):
peta = [
[5, 4, 6, 8, 9], 
[3, 2, 5 ,1, 2], 
[6, 2, 9, 9, 8], 
[5, 1, 2, 3, 4], 
[7, 8, 5, 3, 2]
]
path = []
kemungkinan = []
tempStart = start
for i in range(0,end[0]):
    if tempStart[0] == 0:
        tmp = peta[tempStart[0]+1][0]
        tmp1 = peta[tempStart[0]+1][tempStart[1]+1]
        kemungkinan.append([tmp,tmp1])
        if tmp < tmp1:
            path.append(tmp)
            tempStart = [i+1][0]
        else:
            path.append(tmp1)
            tempStart = [i+1][i+1]
    if tempStart[0] != len(peta) and tempStart[1] != len(peta) and tempStart[0] != 0 and tempStart[1] != 0:
       ...

    if tempStart[0] == len(peta) and tempStart[1] == len(peta):
        ...
print(path)
print(kemungkinan)

proses([0,1],[4,2])


What caused the error and how to fix it? proses([0,1],[4,2]) is part of the code

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
Bubleygum
  • 43
  • 1
  • 1
  • 7
  • 3
    You need to learn how to finx the code in your question. Yes the code in your question is bad syntax, but the error message doesn’t appear to relate to the code, as it’s showingg the input coming from stdin. What exactly are you doing when you get this error? – DisappointedByUnaccountableMod Dec 04 '21 at 09:14
  • 2
    Please add code and data as text ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](//meta.stackoverflow.com/a/285557). Images should only be used, in addition to text in code format, if having the image adds something significant that is not conveyed by just the text code/error/data. – gre_gor Dec 04 '21 at 09:18
  • @balmy i run it in terminal? – Bubleygum Dec 04 '21 at 09:21
  • 1
    @kiner_shah yep, it's fixed, thank you!! – Bubleygum Dec 04 '21 at 09:24

1 Answers1

0

you need an indent after a function

def foo():
print('bar')

will give you an error because there is no indent you need to do

def foo():
    print('bar')

and that will work.

hbblue
  • 305
  • 3
  • 14