I've written this program both in Java and in C++, so now I'm trying to do it in Python. All the program does is use a loop from 1 to 5 and output each number followed by that number squared. It outputs the numbers in columns, so it needs to look like this:
Value Square
1 1
2 4
3 9
4 16
5 25
Here is all I got so far:
def square(x):
return x * x
print "Value Square"
for i in range(1, 6):
print i + " " + square(i)
But of course it's wrong cuz the compiler tells me I can't concatanate and integer with " ". I'm looking for some way to tell the compiler to first print the value of i then move over to the next column, and print that value squared. Then after that, move to the next line and do the same for the next value of i.