I have the user put in 2 words and then I want to put the 2 words in 2 different lists, like:
ask=input("write 2 words here:") Hello world
list1 = ['Hello']
list2 = ['world']
I have the user put in 2 words and then I want to put the 2 words in 2 different lists, like:
ask=input("write 2 words here:") Hello world
list1 = ['Hello']
list2 = ['world']
A possible solution would be:
word1, word2 = input().split()
list1, list2 = [word1], [word2]
so if you want the user to put any number of words, then I suggest using one list containing all other lists. for example:
user_input = input("write some words here:").split()
WordList = []
for word in user_input:
WordList.append( [word] )
print(WordList)
this code creates a list of lists. for recalling any list that you want all you have to do is to use its index like print( WordList[2] )
word_list = []
ask = input("write n words here:") Hello world
split_list = ask.split()
for word in split_list:
word_List.append([word])
#input: hello what is this
print(len(word_list))
# 4
print(word_list)
[['hello'],['what'],['is'],['this']]
# You can access individual word list by their index
print(word_list[0])
# hello