0

How can I extract letters from a single word in Python?

"APPLE" variables: p="A" q="P" r="P" s="L" t="E"

2nd Apr 2020, 8:02 AM
X-PLORE BIPUL
X-PLORE BIPUL - avatar
3 Answers
+ 4
Store the string "APPLE" in a variable, let's say fruit. fruit[0] will return "A" fruit[1] will return "B" And so on. Hope that helps. Use a loop if required. len(string) will return the length of string as an integer.
2nd Apr 2020, 8:15 AM
Bhavya
Bhavya - avatar
+ 2
Just declare a variable.Let str. Then str="APPLE" #assign value At last Print(str[0],end="") Print(str[1],end="") Print(str[2],end="") Print(str[3],end="") Print(str[4],end="") Like this u can print single character of string
2nd Apr 2020, 8:30 AM
Shubham Kumar
Shubham Kumar - avatar