I am having trouble with my reverse list program which is below.
list1 = input ("please enter the list you want to print")
print ("Your List: ", list1)
rlist1 = reversed(list1)
toberlist1 = []
for eachit in rlist1:
toberlist1.append(eachit)
yesno = input ("Press 1 for original list or 2 for reversed list")
yesnoraw = int(yesno)
if yesnoraw == 1:
print (list1)
else:
print (toberlist1)
FYI:the toberlist is short for to be reversed list.
The problem I'm having is that the reversed list is returning:
['s', 'r', 'a', 'e', 'p', ',', 's', 'e', 'l', 'p', 'p', 'a']
When it should be returning just:
sraep,selppa
The square brackets, all but one comma and apostrophes are not needed so how do I remove them.
Help would be appreciated!
EDIT:I apologize for posting this question as someone has already answered it but whoever flagged it saying it has already answered is probably someone who knows a thing or two about programming. I didn't know what was wrong which is why I asked the question in the first place. I didn't know that it was a list of strings which meant I couldn't have possibly known to go to that thread. Also the title checker that tells you if there are similar topics also didn't give me any posts that had a similar question. Once again apologies but as a heads up some of us are bad at programming :-)