- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringList.py
More file actions
Latest commit
executable file
·31 lines (27 loc) · 1.02 KB
/
Copy pathstringList.py
File metadata and controls
executable file
·31 lines (27 loc) · 1.02 KB
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
#!/usr/bin/python3
print("Let us start the word count game")
sent_array= []
"""
sent_array.append("Getting started with python")
sent_array.append("Its 12:15 lunch time")
sent_array.extend(["Hopefully we will break by 5", "Need to get back to regular work"])
"""
print("Input a string to create the database,"
+" input Q or Quit to end the input :")
while1:
in_str=input(">>> ")
ifin_str.lower() =='q'orin_str.lower() =="quit":
print("Let us continue to the word counting game")
break
sent_array.append(in_str)
forsentenceinsent_array:
u_cnt=int(input('Count the number of words in "%s" :'%(sentence)))
words=sentence.split(' ')
print(words)
ifu_cnt!=len(words):
print("You got this wrong its not {u_cnt} but rather {0}".
format(len(words), u_cnt=u_cnt))
ifinput("Do you wish to continue ? press q to end :").lower() =='q':
break
else:
print("Congratulations you got this right lets try the next one")