Answer:
Hi there! The question can easily be implemented by iterating through the array list an using the "startswith()" function of the String class. Please find explanation below.
Explanation:
We can write the code as below into a file called starts_with.py and run it from the command line. Sample input is also provided with results.
starts_with.py
import sys;
def starts_with(prefix, wordlist):
for e in wordlist:
if e.lower().startswith(prefix.lower()):
starts_with_array.append(e);
starts_with_array = [];
prefix = input("Enter prefix: ");
wordlist = input("Enter word list: ");
wordlist = wordlist.split(',');
starts_with(prefix, wordlist);
print(starts_with_array);
Usage with Result
> starts_with.py
> Enter prefix: Fun
> Enter word list: Funtastic,Fun,Test,No
> ['Funtastic', 'Fun']
1.) Business Engineering or Manufacturing :)
<span />
Answer:
local Area Network, Wide Local Area Network and Personal Area Network