FirstName = raw_input("Please enter your first name: ")
Scores = map(int, raw_input("Please enter your four golf scores: ").split())
print "Score analysis for %s:" % FirstName
print "Your golf scores are: " + Scores
print "The lowest score is " + min(Scores)
print "The highest score is" +max(Scores)
I am trying to convert a basic program I wrote in C++ to python and I want to input an array of 4 integers, then compute the min, max and a few other things. I want the user to be able to enter the four scores like "70 71 72 73" and then store those four as an array(list?) of four integers.
Thanks for any help!
The error I see when I run your code is about string formatting of the output, not the reading of the input. One way to correct the code is shown below. I changed the string+list error to use the print
statement's comma. I changed the two string+int errors to use string interpolation.
FirstName = raw_input("Please enter your first name: ")
Scores = map(int, raw_input("Please enter your four golf scores: ").split())
print "Score analysis for %s:" % FirstName
print "Your golf scores are:", Scores
print "The lowest score is %d" % min(Scores)
print "The highest score is %d" % max(Scores)