. Advertisement .
..3..
. Advertisement .
..4..
I get a “syntaxerror: non default argument follows default argument” error when I run the following code
from os import system
def exam(len1,hgt=len1,til,col=0):
system('mode con cols='+len1,'lines='+hgt)
system('title',til)
system('color',col)
exam(61,22,"hi","0b")
input()
How to fix ? Give me some tips that can help me fix it.
Two things you should do here in order to make the syntax error removed
1/ Your arguments order should be re-arranged, for reminder, you should respect the order: defaut -> keyword -> arbitrary arguments. You could read more about that on https://realpython.com/lessons/ordering-arguments-function/
2/ Remove ‘hgt=len1’ because it is not authorized here
I hope this may help you. Thanks for leaving feedback.
The Python “SyntaxError: non-default argument follows default argument” error is raised when you specify a default argument before a non-default argument. To solve this error, make sure that you arrange all the arguments in a function so that default arguments come after non-default arguments. So remove this “len1 = hgt” it’s not allowed in python