Home>

The following code is written using Python3. When you execute it, you will be asked to enter the name of the dictionary key. Is it possible to complete the character by pressing the tab key at that time?

For example, when>>"ya"is input and the tab key is pressed,"yahoo"is input (complemented).

Because i am a beginner and don't know anything, it would be helpful to lend us your wisdom!

import webbrowser
url_dic = {
    "google": "https://www.google.com/",
    "bing": "https://www.bing.com/"
}
name = input (("choose one from the list below \ n {} \ n" .format (url_dic.keys ())))
if name in url_dic.keys ():
    webbrowser.open (url_dic [name])
else:
    print ("quit")
  • Answer # 1

    Try searching for

    https://stackoverflow.com/questions/5637124/tab-completion-in-pythons-raw-input

  • Answer # 2

    "python command-line completion"