-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise7.py
More file actions
31 lines (26 loc) · 984 Bytes
/
Copy pathexercise7.py
File metadata and controls
31 lines (26 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def char_count(s):
char_count = {}
for char in s:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1
return char_count
print(char_count("hello"))
def char_count(s):
result = {}
for char in s:
if char in result:
result[char] += 1
else:
result[char] = 1
return result
print(char_count("hello"))
#sorry again but i have another question
#when writing a program like the one's above which method is better and professional
#the first called out the of func through out the program
#and the second uses result[] in program
#they both give the same answer they practical identical
#but if there's any thing i learnt in journey so far is that nothing as it seems
#i would realy like your input on this i know i can ask AI or many outlet for ans but want limit how much i depend on AI and external interferences in my work
#thanks