0

How to list out the alphabets of a name using for loop in python

Python

4th May 2023, 7:13 AM
Divya Dharsini Murugesan
Divya Dharsini Murugesan - avatar
8 Answers
+ 6
Please, explain your question better, and show your attempt. Else we can’t help you more 😐
4th May 2023, 7:19 AM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 4
Divya Dharsini Murugesan , your description is a bit vague, so please give sample of input and how the output should look like. we already have 2 assumptions, and there could be an other one: "testcases" => {'t': 2, 'e': 2, 's': 3, 'c': 1, 'a': 1}
4th May 2023, 3:16 PM
Lothar
Lothar - avatar
+ 4
Ugulberto SĂĄnchez , the only thing we can do for the moment is guessing, what we should avoid. the op is expecting helpful hints, so we can expect a proper description and the code attempt from him - right?
4th May 2023, 4:51 PM
Lothar
Lothar - avatar
+ 3
If you mean ordering a list of strings or other datatype: [“hello”, “abc”, “sololearn”] Use sorted() function: sorted([“hello”, “abc”, “sololearn”] -> [“abc”, “hello”, “sololearn”]
4th May 2023, 7:18 AM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 3
Why not just do: name = input() #Take the name as a string alphabet_list = list(name) #transforms name into a list of characters print(alphabet_list) #Print it to the output. Or just one line of code: print(list(input()))
4th May 2023, 3:17 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 2
name = "John" alphabet_list = [i for i in name] print(alphabet_list) Explanation: >> name = input() This line of code prompts the user to enter a name and stores the input value in the name variable. >> alphabet_list = [i for i in name] This line of code uses a list comprehension to create a new list called alphabet_list. The list comprehension iterates through each character i in the name string and appends it to the alphabet_list list. >> print(alphabet_list) This line of code outputs the alphabet_list to the console. Input: John Output: ['J', 'o', 'h', 'n']
4th May 2023, 8:30 AM
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ
FꫀâČ…áƒ«á„†ÍŸá„™á„‰áŻœ - avatar
+ 2
Lothar so just wait 😐
4th May 2023, 4:53 PM
Ugulberto SĂĄnchez
Ugulberto SĂĄnchez - avatar
+ 1
Divya Dharsini Murugesan What in the world is an alphabet of a name?
5th May 2023, 3:07 AM
Emerson Prado
Emerson Prado - avatar