ValueError: cannot switch from manual field specification to automatic field numbering
return "{0} by {1} on {}".format(self.title, self.author, self.press)
that doesn't work. If you specify positions, you have to do it through the end:
return "{0} by {1} on {2}".format(self.title, self.author, self.press)
In your case, best is to leave python treat that automatically:
return "{} by {} on {}".format(self.title, self.author, self.press)
Well if can give a proper output in a table format ifinstead of using format go for f"" ;
for e.g
<!DOCTYPE html><html><head> <title><strong>Unable to handle Value Error</strong></title></head><body><p><ol>for name, branch,year in college:</ol> <ol> print(f"{name:{10}} {branch:{20}} {year:{12}} )</ol> <ol>name branch year </ol> <ol>ankit cse 2</ol> <ol>vijay ece 4</ol><ol> raj IT 1</ol></body></html>
You are mainly seeing this error because you have used empty flower braces which says python to use default numbering, and later you have specified numbers in the replacement fields. Thus creating confusion to the interpreter.
print ("{0} by {1} on {}".format(self.title, self.author, self.press))
here {} mean start with 1st replacement field and follow till end not 0 as like in slicing which starts with zero.
to clear this error you can use
print ("{0} by {1} on {2}".format(self.title, self.author, self.press))
print ("{} by {} on {}".format(self.title, self.author, self.press))