5 Respostas
+ 3
Nicola Esu Do you mean so:
https://code.sololearn.com/ctMV1cdtJy3L/?ref=app
+ 1
If you are talking about the number of digits, then you may want to use "len" string method to get the number of characters (digits) then assign to "counter" variable but make sure you get the input as string.
Or if you are talking about the count of each digits in the input, then you may want to iterate and count each digit and store it to a dictionary named "counter", with digits as keys, and their frequency are their value.
0
Yes, you can do it.
Say, you want to count how many even numbers are there up to 20. In python, the logic would be like
count=0
for i in range (21):
if i%2==0:
count+=1
print(count)
Or another approach
list=[]
for i in range (21):
if i%2==0:
list.append(i)
print(len(list))
0
I would like to create a calculator that keeps track of all operations before printing the result
0
in c
a = 0
b
counter = 0
scanf(“%d”, & a),
counter = counter + a,
a = 0,