'(Replacement index 1 out of range for positional args tuple) what's wrong?
What's wrong with my code?
marks = {"sungin": 80, "joonghyuk": 100,"sangsun": 70}
for mark in marks:
if marks[mark] >90:
print("{} {} pass".format(mark), marks[mark])
else:
print("{} {} fail".format(mark), marks[mark])
I'm getting the error:
Traceback (most recent call last):
File "main.py", line 8, in <module>
print("{} {} fail".format(mark), marks[mark])
IndexError: Replacement index 1 out of range for positional args tuple
Solution 1:[1]
There is syntactical error in your code with the closing paranthesis. Please rectify your code per below.
marks = {"sungin":80, "joonghyuk":100,"sangsun":70}
for mark in marks:
if marks[mark] >90:
print("{} {} pass" .format(mark, marks[mark]))
else:
print("{} {} fail" .format(mark, marks[mark]))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Alonso |
