+ 2
How to correct the Invalidsyntax Error in line 7?
I have a list and want to input a digit so that the output is the list's element on the respective position. The variable "word" is supposed to be that digit representing the position, starting from 1 up to len(list). Why is there an InvalidSyntaxError in line 7? 1 command=input() 2 word=input() 3 if command=='pos': 4 if word.isdigit(): 5 if 1<=int(word)<=len(list): 6 print('element on position',str(word),+':'+str(list(word-1)) 7 else: 8 print('Position',word,'out of range.') 9 else: 10 print('Error: Enter digit.') Thank You in advance!
2 Answers
+ 6
There is a missing closing bracket at line 7
+ 4
...and a comma in b/w str(word) and ':' (line 6)