Reputation: 15
When I am printing the list, there is a comma and quotations in the letter X, how do I remove it?
#asks user input
m = int(input("Enter number of boxes horizontally and vertically: "))
n = int(input("Enter number of mines: "))
a=[]
for i in range(m):
a.append([])
for k in range(m):
a[i].append("X")
i=1
#prints the generated cells
for i in range(m):
print a[i]
i=i+1
Upvotes: 0
Views: 2427
Reputation: 26600
You are looking to use join
to make your list in to a string. You want to make your string space separated, so you will want to use ' '.join()
:
Change this:
print a[i]
to this:
print(' '.join(a[i]))
Or, if you are mixing types, you should do:
' '.join(str(x) for x in a)
Upvotes: 2