Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23276

splitting a list of an input into seperate words

$
0
0

I need input to be put into separate words in a list.

What I have right now:

lines = []last_line = []while True:    cmd = input("-")    if cmd == "del":        print("~deleted")        last_line.clear()    elif cmd == "line":        lines.append(last_line)        last_line.clear()        last_line.append(input("~line: "))    elif cmd == "show":        split = [word for word in lines[0].split(" ")]    else:        print("~invalid command")

What I want it to do, is when I type "show" it shows what has been inputted, but in separate parts of the list.I realise that this is not very clear, so what I mean is that at 'split = [word for word in lines[0].split(" ")]' isn't working, and I don't know what to put there.


Viewing all articles
Browse latest Browse all 23276

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>