Skip to content

Instantly share code, notes, and snippets.

@ThattaPY
Last active March 6, 2022 18:31
Show Gist options
  • Save ThattaPY/f8b2f1a920cbe4628cfc323639da44bc to your computer and use it in GitHub Desktop.
Save ThattaPY/f8b2f1a920cbe4628cfc323639da44bc to your computer and use it in GitHub Desktop.
Complex input convert the user input to a ls type that have two ls types into.
# this def is use to strip an input to ls types, one for string other is to put the integer types
# maybe use to take NLP inputs
def main_input():
num_tokens = []
str_tokens = []
user_input = input("Insert Data: ")
token_words = user_input.split(sep=" ") # .split method cuts the chain
for token in token_words:
if token.isnumeric(): # return false or true depend of token value type
num_tokens.append(token) # .append add a value t a list
else:
token.strip() # .strip method remove before and after spaces
str_tokens.append(token)
token_data = str_tokens, num_tokens # create a combined variable with both appended list
return token_data
print(main_input())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment