fork download
  1.  
  2. def longcomstr(l):
  3. c=l[0]
  4. s=''
  5. n=len(c)
  6. for i in range(1,len(l)):
  7. for j in range(0,len(l) and n):
  8. if c[j]!=l[i][j]:
  9. break
  10. s=s+c[j]
  11. print(s)
  12. def main():
  13. try:
  14. strarr=input()
  15. l=strarr.split()
  16. longcomstr(l)
  17. except:
  18. print('invalid')
  19.  
  20. main()
Success #stdin #stdout 0.01s 118784KB
stdin
2 
VIP
VIP
stdout
invalid