Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
str(pd.MultiIndex.from_tuples([('c' * 62,)]))

Issue Description

This code will return the following error when the length is 62 or more:

File "pandas/core/indexes/base.py", line 1233, in __repr__
    data = self._format_data()
  File "pandas/core/indexes/base.py", line 1275, in _format_data
    return format_object_summary(
  File "pandas/io/formats/printing.py", line 448, in format_object_summary
    summary, line = _extend_line(summary, line, tail[-1], display_width - 2, space2)
  File "pandas/io/formats/printing.py", line 360, in _extend_line
    if adj.len(line.rstrip()) + adj.len(value.rstrip()) >= display_width:
AttributeError: 'tuple' object has no attribute 'rstrip'

Expected Behavior

The code shouldn't fail

Installed Versions

INSTALLED VERSIONS ------------------ commit : 37ea63d540fd27274cad6585082c91b1283f963d python : 3.10.7.final.0 python-bits : 64 OS : Linux OS-release : 5.4.0-147-generic Version : #164~18.04.1-Ubuntu SMP Tue Apr 4 00:20:20 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.0.1 numpy : 1.24.3 pytz : 2022.7.1 dateutil : 2.8.2 setuptools : 63.2.0 pip : 23.0.1 Cython : None pytest : 7.3.1 hypothesis : 6.72.1 sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.6 jinja2 : 3.1.2 IPython : None pandas_datareader: None bs4 : 4.12.2 bottleneck : None brotli : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : 2.8.4 odfpy : None openpyxl : None pandas_gbq : None pyarrow : 11.0.0 pyreadstat : None pyxlsb : None s3fs : None scipy : None snappy : None sqlalchemy : 2.0.10 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None

Comment From: asishm-wk

likely caused by https://github.com/pandas-dev/pandas/pull/49740

where the

head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]

block was moved from outside the for loop to the inside

Comment From: Charlie-XIAO

take