How to print a list without brackets or quotes or commas

Viewed 51
user_input = input()
x = user_input.split()
print(x)

if len(x) % 2 == 0:
    y = 'even'

if len(x) % 2 != 0:
    y = 'odd'

list1 = []
list2 = []
if y == 'even':
    list1.append(x[::2])
    list2.append(x[1::2])
    print(*list1, sep=' ')
    print(*list2, sep=' ')
if y == 'odd':
    print('INVALID INPUT')

a sample input would be

"This is a test" 

It's just a simple list maker that I'm trying to get figured out. For some reason, the (*list1, sep='') is still printing as a full list. When I left it as just print(list1) it looked it was a list inside a list.

I'm trying to print the lists without commas, brackets, or quotes.

1 Answers
#list1 and list2 are created with slicing
#join is used to convert the list into a string

user_input = input()
x = user_input.split()
print(x)

if len(x) % 2 == 0:
    y = 'even'

if len(x) % 2 != 0:
    y = 'odd'

#print(x,y)
if y == 'even':
    list1=x[::2]
    list2=x[1::2]
    print(list1,list2)
    print(' '.join(list1[::1]))
    print(' '.join(list2[::1]))
if y == 'odd':
    print('INVALID INPUT')

#output
This is a test
['This', 'is', 'a', 'test']
['This', 'a'] ['is', 'test']
This a
is test
Related