Reputation:
I get the error "SyntaxError: invalid syntax", though I am not really sure why:
print("ChiSquare Elektronen, Myonen, Tauonen und Hadronen %d",%( chisquare(fitElectrons, wertElectrons, errorE[0]), chisquare(fitMyons, wertMyons, errorE[0]), chisquare(fitTauons, wertTauons, errorE[0]), chisquare(fitHadrons, wertHadrons, errorE[0]) )
Upvotes: 1
Views: 59
Reputation: 21
The comma is not required before the %
or modulus.
Correct syntax : print("ChiSquare Elektronen, Myonen, Tauonen und Hadronen %d" %( 1 ))
Additionally, you do not have a valid int type on the right-hand side of the % operator.
They seems be, for example : 1,3,5,2
This cannot be converted to float as this contains the ,
.
Rather use it this way:
print("ChiSquare Elektronen, Myonen, Tauonen und Hadronen %d %d %d %d" %(1,3,5,2))
or
print("ChiSquare zum Elektronen ist %d, zum Myonen ist %d, zum Tauonen ist %d und zum Hadronen ist %d" %(1,3,5,2))
Upvotes: 2
Reputation:
Unfortunately, the suggested comments do NOT work for me. However, the following line works (cf. TypeError: not all arguments converted during string formatting python for more details):
print("ChiSquare Elektronen, Myonen, Tauonen und Hadronen '{0}, {1}, {2}, {3}'" .format( chisquare(fitElectrons, wertElectrons, errorE[0]), chisquare(fitMyons, wertMyons, errorE[0]), chisquare(fitTauons, wertTauons, errorE[0]), chisquare(fitHadrons, wertHadrons, errorE[0])))
Upvotes: 0