Python Forum
How to split the input taken from user into a single character? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to split the input taken from user into a single character? (/thread-37975.html)



How to split the input taken from user into a single character? - mHosseinDS86 - Aug-17-2022

Hi there everyone,
Hope you guys are doing awesome coding! I'm new and learning python. I just wanted to ask you guys that I want to take the input from user which can be done by using input() function, Now I want to split all the characters typed in by the user into single character. I can use split() function for the purpose but that wouldn't do the job I wanted.
How should I do it? Kindly explain the step for assistance.
Thanks in advance! God Bless you all.


RE: How to split the input taken from user into a single character? - menator01 - Aug-17-2022

Is this what you after?

string = input()
string = list(string)
print(string)



RE: How to split the input taken from user into a single character? - mHosseinDS86 - Aug-17-2022

(Aug-17-2022, 10:10 AM)menator01 Wrote: Is this what you after?

string = input()
string = list(string)
print(string)

Thanks for replying menator01.


RE: How to split the input taken from user into a single character? - Pedroski55 - Aug-17-2022

For my own use, I sometimes need to .split() input to get the top left and bottom right of a rectangle.
I keep doing this in a while loop, until I am happy with the result jpg.

I do:

nums = input('Enter the coordinates you want, separated by a space ... ')
Then I enter something like:

50 300 1500 2000

coords = nums.split()
which gives me a list of 4 numbers [50, 300, 1500, 2000} I can pass to Image to crop the picture.