How to split user input in python?
For example : i want to split golden to 'g','o','l','d','e','n'.... THANK YOU!
inp = input("Your input here") splitted = list(inp) Now splitted is a list with values like this :- Suppose I gave input as Sololearn :- splitted = ['S','o','l','o','l','e','a','r','n']
@Ace :- split() doesn't work here For example :- a = "Nikhil" b = a.split() print(b) would just print ['Nikhil'] It doesn't split.
Nikhil split() function splits a string by spaces into words, am I right?
St= St=input ("enter a string") For x in st: Print (st[0::])
U could try the .extend() method For example a= "Nikhil" b= a.extend()
If you want it in one line use: var1 = input() var2 = list(var1) print(var2) Or if you want it in separate lines: var1 = input() for var2 in var1: print(var2)
Why dont you use for loop in compination with list For example: Word = input() Split_word =  For i in word: Split_word.append(i) This works better and simple 👌🏻
love=input("insert your verb") splitted=list(love) print(splitted) My Input = i love universe ["I","l","o","v","e", im lazy etc.....]
inp = input("Your input here") splitted = list(inp) Here I'm using, Ritviz:- splitted = ['R','i','t','v','i','z']
If you mean a string you can split strings in python they are a form of list
text = input() stext= [x for x in text] print(stext)
name= input (what's yourname)
Use list function
Put \n Before them
Just use .. splitted = ['S','o','l','o','l','e','a','r','n']
Use split() function
You can use `list()` function, user_inp = input("enter input: ") splitted_string = list(user_inp) Now print the splitted_string variable to the desired output print (splitted_string)
No need to split or anything you can simply acees it with array index for ex Name = input ("enter your name") Print(name) //Suppose name is nikhil then it will print n which is the first character present at index 0.
What is indentations... ?
Application RAM usage