+ 5
Python
I wanna read the string and make it to list .reading string depends up on input of the user
15 Respostas
+ 6
n = input()
for i in range(0,n):
List=[]
Str=input()
List.append(str)
print(list)
## output should be like ['a','b']
## but I'm getting ['a']
['b']
When n=2
+ 4
Tq guys
+ 3
n = int(input())
while n > 0:
list = str(input())
n-=1
print(list(list)
Output should be in list eg['gah',faha] # n=2
+ 3
Ajith could you please reframe your question? I really do not know how to help here. Are you trying to split the second input based on the first input?
Eg.
Input:
3
"Reframe your question properly"
Output:
["Reframe", "your", "question"]
+ 3
print (input().split(" "))
Read a string split it by spaces
Input : a b
Output ['a','b']
+ 2
# input example
# >>2
# >>gah
# >>faha
n = int(input())
list = []
while n > 0:
list.append(input())
n -= 1
print(list)
# Output: ['gah','faha']
+ 1
Ajith take this
list=[]
outside the loop then check it
it will work
otherwise your code was correct
+ 1
t = input().split()
for index, word in enumerate(t):
for char in word:
if char.isalnum() == False:
t[index] = word.replace(char, "")
print(t) # You should get a list of words and numeric strings without special characters.
0
ĐŻ ĐŁĐșŃĐ°ĐčĐœĐ”ŃŃ. From Ukraine no speak English.
0
Yes!
0
list = list (input())
print (list)
0
n = int (input())
print (list[:n])
0
ĐŻ ŃĐșŃĐ°ŃĐœĐ”ŃŃ
0
instring = str(input())
inlist = list (instring) #this converts each character into elements of list
inwords = instring.split() #this converts each word in the string into elemnts of list
print (inlist)
print (inwords)
example: for input â Hi allâ, the output will be
[âHâ, âiâ, â â, âaâ, âlâ, âlâ,]
[âHiâ, âallâ]
0
SHE SHE