How we will print the index value of the given number.(If we would like to print the last index occurrence of the given number in the list, what modification we should do in the above described code?) Please reply.
how to count the number of occurrences of the second parameter within the first parameter string? like - number of occurrences "iss" string in "mississippi".thanks
print("The occurances of each and every letter are ",dic)
print("The occurances of {} are {}".format(n,dic[n]))
countOccurancesInString("mississippi", "s") The occurances of each and every letter are Counter({'i': 4, 's': 4, 'p': 2, 'm': 1}) The occurances of s are 4
Thank you Sir.By using loop method ,it is giving output multiple times like "10 has occurred 3 times".This statement repeats multiple times.Any Reason ?
my_list = [10,15,25,10,35,45,10,5,2,4,1] x = 10 length = len(my_list) count =0 for i in range(length): if my_list[i] ==x: a = i print(a) Please check, is this correct to find the last occurrence
n=[15,6,7,10,12,20,10,28,10]
a=10
count=0
for i in n:
if i==a:
count=count+1
print(count)
I don't want to assign a value of x to be counted, i want a program which automatically counts all the occurances
Me too
@@PRADEEPCHOUDHARY. Same
Same
@Vasto Lorde yesss... it's working 👏
I have been searching for this exact video for hours this has helped me so much!!!
def count(arr, i, dictionary):
if i >= len(arr):
return dictionary
if arr[i] in dictionary:
dictionary[arr[i]] += 1
else:
dictionary[arr[i]] = 1
return count(arr, i+1, dictionary)
print(count([1,1,2,3,4,5,1],0,{}))
Which method tells the no. of objects stored in object of particular type
How we will print the index value of the given number.(If we would like to print the last index occurrence of the given number in the list, what modification we should do in the above described code?) Please reply.
how to count the number of occurrences of the second parameter within the first parameter string? like - number of occurrences "iss" string in "mississippi".thanks
def countOccurancesInString(s, n):
dic = Counter(s)
print("The occurances of each and every letter are ",dic)
print("The occurances of {} are {}".format(n,dic[n]))
countOccurancesInString("mississippi", "s")
The occurances of each and every letter are Counter({'i': 4, 's': 4, 'p': 2, 'm': 1})
The occurances of s are 4
what if we are supposed to count duplicates in a list entered by user 'n' times
How can I choose to count how many times 2 characters appear in a text ?
For example how many "th" in text "abc" ?
What if count of two numbers are equal? How to solve that one?
😢
How to do without variable x??
Same query
Thank you Sir.By using loop method ,it is giving output multiple times like "10 has occurred 3 times".This statement repeats multiple times.Any Reason ?
keep the print statement outside of the loop body
how do i ascend or descend it from collection library?
my_list = [10,15,25,10,35,45,10,5,2,4,1]
x = 10
length = len(my_list)
count =0
for i in range(length):
if my_list[i] ==x:
a = i
print(a)
Please check, is this correct to find the last occurrence
Thank you! But can you explain please how to count ALL elements so it will look like:
10 - 2
5 - 1
6 - 1
etc..
write a python programme to check the given list is having first value as integer or not using if else statement. Anyone help me with that 😁
nice video
Thanks
Sir I only want the frequency not the character 😭😭
And also all the elements
def count(arr, i, dictionary):
if i >= len(arr):
return dictionary
if arr[i] in dictionary:
dictionary[arr[i]] += 1
else:
dictionary[arr[i]] = 1
return count(arr, i+1, dictionary)
print(count(["hello", "world"],0,{}))