Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to give autocomplete in python

import readline
readline.parse_and_bind("tab: complete")

def complete(text,state):
    volcab = ['dog','cat','rabbit','bird','slug','snail']
    results = [x for x in volcab if x.startswith(text)] + [None]
    return results[state]

readline.set_completer(complete)

line = input('prompt> ')
Comment

PREVIOUS NEXT
Code Example
Python :: pd df append 
Python :: python program to add two numbers using function 
Python :: python check tuple length 
Python :: Write a Python program to count the number of lines in a text file. 
Python :: delete tuple from list 
Python :: python acf and pacf code 
Python :: abc python 
Python :: time 
Python :: check if a list contains any item from another list python 
Python :: python how to get the folder name of a file 
Python :: last index in python 
Python :: find the highest 3 values in a dictionary. 
Python :: find the difference in python 
Python :: python change character in string 
Python :: twitter api v2 python tweepy 
Python :: keras lstm example 
Python :: split a string with 2 char each in python 
Python :: flatten columns after pivot pandas 
Python :: relative path django 
Python :: random.choice 
Python :: python hide print output 
Python :: catch error data with except python 
Python :: push element to list python 
Python :: flask debugtoolbar 
Python :: read json in python 
Python :: pandas dataframe column based on another column 
Python :: kivy button on click 
Python :: Calculate Euclidean Distance in Python 
Python :: tqdm range python 
Python :: c++ vs python 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =