- Home
- Course Detail
regularpython@gmail.com
You are now watching:
Python Lists / of Python List Real-Time Examples
import MySQLdb from beautifultable import BeautifulTable table = BeautifulTable() table.column_headers = ["Movie Name", "Movie Language"] table.column_alignments['Movie Name'] = BeautifulTable.ALIGN_LEFT try: connection = MySQLdb.connect(user='root',password='sairam143sairam',port=3306,host='localhost') except Exception as e: print(e) else: tutorialCursor = connection.cursor() tutorialCursor.execute("SELECT movie_name,movie_language FROM bulkratings_info.tutorialstution_movies_list;") Books = tutorialCursor.fetchall() connection.close() moviesList = [] for Book in Books: try: #Append Inbuilt fumction moviesList.append(Book) except: pass # print(moviesList) print(len(moviesList)) moviesList = moviesList[10:20] # print(len(moviesList)) moviesList.sort(key=lambda x:x[1].lower(), reverse=False) for movie in moviesList: table.append_row(movie) print(table)