L
L
Leslies2020-05-31 18:09:02
Python
Leslies, 2020-05-31 18:09:02

How to remove commas in an answer?

Hello, I have this code:

n = 5
k = 3
def genkinv(n, k):
a = []
while n > 0:
if k > n - 1:
a.append(n)
k -= (n - 1)
n -= 1
else:
for i in range(1, n - k):
a.append(i)
a.append(n)
for i in range(n - k, n):
a.append(i)
k = 0
n = 0
return a print ( genkinv
(n,k))

how to change the code so that the answer is not separated by commas, but by a space?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-05-31
@Leslies

result = genkinv(n,k)
print (' '.join(str(c) for c in result))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question