0
from tabulate import tabulate as t
class INFO_SETUP():
  def infoSort(self,name):
    print("Format of table is:","Name","Phone Number","Office Location",sep="\n")
    global StaffName
    global StaffPhone
    global StaffOffice
    StaffName = ["Faran","Yahya","Hamza","Aliya","Zainab","Hashim","Kilian","Messi","Fatima","Imaan","Francis"]
    StaffPhone = [4374312,2784916,4009234,7859612,3469871,8376482,2385015,9091245,2551085,1745748,9375123]
    StaffOffice = ["London","Toronto","Riyadh","London","Washington","Indiana","Paris","Buenos Aires","Vaduz","Vatican City","Adelaide"]
    sorted(zip(StaffName,StaffPhone,StaffOffice))
    StaffName, StaffPhone, StaffOffice = zip(*sorted(zip(StaffName,StaffPhone,StaffOffice)))
    Info=[StaffName,StaffPhone,StaffOffice]
    table = t(Info, tablefmt='fancy_grid')
    print(table)
    for x in range(0,len(StaffName)):
      if name==StaffName[x]:
        print("Name Found",name,StaffPhone[x],StaffOffice[x],sep="\n")
a=input("Enter Name → ")
INFO_SETUP().infoSort(a)

the result:

Enter Name → Faran
Format of table is:
Name
Phone Number
Office Location
╒═════════╤═════════╤═════════╤══════════╤═════════╤═════════╤══════════════╤═════════╤══════════════╤════════════════╤═══════════════════╕
│         │         │         │          │         │         │              │         │ Name         │ Phone Number   │ Office Location   │
╞═════════╪═════════╪═════════╪══════════╪═════════╪═════════╪══════════════╪═════════╪══════════════╪════════════════╪═══════════════════╡
│ Aliya   │ Faran   │ Fatima  │ Francis  │ Hamza   │ Hashim  │ Imaan        │ Kilian  │ Messi        │ Yahya          │ Zainab            │
├─────────┼─────────┼─────────┼──────────┼─────────┼─────────┼──────────────┼─────────┼──────────────┼────────────────┼───────────────────┤
│ 7859612 │ 4374312 │ 2551085 │ 9375123  │ 4009234 │ 8376482 │ 1745748      │ 2385015 │ 9091245      │ 2784916        │ 3469871           │
├─────────┼─────────┼─────────┼──────────┼─────────┼─────────┼──────────────┼─────────┼──────────────┼────────────────┼───────────────────┤
│ London  │ London  │ Vaduz   │ Adelaide │ Riyadh  │ Indiana │ Vatican City │ Paris   │ Buenos Aires │ Toronto        │ Washington        │
╘═════════╧═════════╧═════════╧══════════╧═════════╧═════════╧══════════════╧═════════╧══════════════╧════════════════╧═══════════════════╛
Name Found
Faran
4374312
London

I want it to say in the first column, the name then the phone number then the office location and finally start with the array. I don't want the phone number, office location and name to be in rows

D.L
  • 4,339
  • 5
  • 22
  • 45

0 Answers0