Skip to content

Latest commit

 

History

History
14 lines (8 loc) · 959 Bytes

autocomplete.md

File metadata and controls

14 lines (8 loc) · 959 Bytes

Autocomplete

Tags: minimicro, farmtronics

Write a program that prompts the user to enter a (partial) word, and then prints all the words in /sys/data/englishWords.txt that start with that input. For example, if the user enters "awes", the program should print awes, awesome, awesomely, awesomeness, and awestruck.

Hints

You'll need to use the file module to read all lines of the file. The result will be a list, which you can iterate over with a for loop and see if it starts with the user's input.

The easiest way to check that would be to first import "stringUtil", so then you can use the .startsWith method. Alternatively, you could just check whether (1) the word under consideration is at least as long as the input word, and (2) a substring of the word, up to the length of the input word, equals the input word.