please help me out to code in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

please help me out to code in python

Let us assume paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For example letters "A", "D", "O", "P", "R" divide the plane into two regions so we say these letters each have one hole. Similarly, letter "B" has two holes and letters such as "C", "E", "F", "K" have no holes. We say that the number of holes in the text is equal to the total number of holes in the letters of the text. Write a program to determine how many holes are in a given text. Input Format: The only line contains a non-empty text composed only of uppercase letters of English alphabet. Output Format: output a single line containing the number of holes in the corresponding text. Example-1 Input: DRINKEATCODE Output: 5

2nd Oct 2018, 7:42 AM
Sujithra
8 Answers
+ 2
I had this: a1 = ["A","D","O","P","Q","R"] a2 = ["B"] s = input().upper() t = 0 for i in s: if i in a1: t += 1 if i in a2: t += 2 print(t)
2nd Oct 2018, 8:47 AM
Paul
Paul - avatar
+ 6
def namec(name): s=range(len(name)) i=count=0 for i in s: print(name[i]) if name[i]=='a'or'd'or'o' or'p' or'r' count+=1 if name[i]=='b' count+=2 print(count) name =input() print(namec(name))
2nd Oct 2018, 8:44 AM
Sujithra
+ 6
u made it very simple...wow..i just want 2 practice more
2nd Oct 2018, 8:49 AM
Sujithra
+ 5
no that's not my idea... i tried a lot but i can't get that perfect output. i just need help
2nd Oct 2018, 7:46 AM
Sujithra
+ 2
Make two lists like this, one for letters with one hole, one for letters with two: a1 = ["A","D","O","P","Q","R"] a2 = ["B"] make a counter and set it to 0 ask for input test for each letter from the input if it is in one of the lists. If it is in list 1, add 1 to the counter, if it is in list 2, add 2. print the counter.
2nd Oct 2018, 8:33 AM
Paul
Paul - avatar
0
WHERE IS YOUR TRY? Do you want that other users make YOUR assignement?
2nd Oct 2018, 7:44 AM
KrOW
KrOW - avatar
0
Sujithra.B Then save your code on "Code Playground" section and copy paste his url here
2nd Oct 2018, 7:47 AM
KrOW
KrOW - avatar
0
a=input() a=a.upper() count=0 a1=["A", "D", "O", "P", "R"] for i in a: for j in a1: if i==j: count+=1 continue if i=="B": count+=2 print(count,end="")
20th Oct 2019, 6:17 AM
Diksha Deb
Diksha Deb - avatar