The number of replications of the character in the string
Write a function that returns the number of repetition of a character in a string
You should not use ready -made functions for this question
count_char("hooshang", "o") #2
Write a function that returns the number of repetition of a character in a string
You should not use ready -made functions for this question
count_char("hooshang", "o") #2
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
```def duplicate_string(string,char): """ این تابع برای نشان دادن تعداد حروف تکراری در یک استرینگ است """ # Wear the variable value zero and the desired string with the circle count = 0 for i in string : if i == char: # If the characters in the navigation were one with our second entrance count += 1 # Add one number to Kant return count # Print out the output # Frequently function and give two inputs to the function filter_char = duplicate_string("mohammad","m") print(filter_char)```
function count_1(s, c) { let count = 0; for (let char in s) { if (char === c) { count += 1; } } return count; } const result = count_1("h", "o"); console.log(result);
def count_char(txt,char): count=0 for i in t: if c==i: count+=1 print(count if count>0 else 'nout found') t=input('enter your text: ') c=input('enter your char: ') count_char(t,c)
def string_txt(s): my_text = {} for item in s: if item in my_text: my_text[item] += 1 else: my_text[item] = 1 return my_text
def chek_try_str(string,char): return string.count(char) text=input('input one string:') char=input('input char for count:') print(f"the character appears'{char}',{chek_try_str(text,char)} times in the string.")
def count(x,y): l=[] for i in x: l.append(i) l2=filter(lambda x : True if x==y else False , l) return len(list(l2)) print(count('hooshang',"o")) #2
# Number def count_char(string, char): return string.count(char) print(count_char("hooshang", "o"))
Submitting answers is currently unavailable.
Scissors Paper Play: 1- The user chooses one between paper or scissors. 2- Select the system by random. 3- With the choice of user and system, the result is displayed and the user's rating is calculated 4- ... ...
Design the database of a restaurant and write a query about making tables and keys. Tips: In this restaurant we want to have a list of foods, orders and customers in the system
Write a program that receives a text and a word from the user, search the word in the text, and as the example below and then put the word * and print the text in the output. Example: Input1: Hello. My name is hooshang. I ...
We have a list of different items along with their discount percentage and we want to know how much the final price of each product is after considering the discount. Write a program that gets the product price as below and the percentage of discount ...
We want to open the cow door, we don't know the password, but we have the following information: the second -digit safing password and the fifth digit equivalent to the first number of the first digit of a larger unit ...
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.