Python Forum
Type Error: bad operand type for unary +: 'str'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Type Error: bad operand type for unary +: 'str'
#2
(Aug-12-2019, 04:00 AM)Psypher1 Wrote: I'm assuming that's where the issue is
The error message gives you detailed information where and what is wrong.
So when asking for help providing this error message is a vital thing to do.
Without we can only guess that likely here
                elif item == 1:
                    colored_row += Fore.GREEN + ' X ' + + Style.RESET_ALL
                elif item == 2:
                    colored_row += Fore.MAGENTA + ' O ' + + Style.RESET_ALL
you need to convert the constants Fore.<color> and Style.RESET_ALL into strings
OR if these are strings than the error is due to the double + + in these lines.
                elif item == 1:
                    colored_row += str(Fore.GREEN) + ' X ' + str(Style.RESET_ALL)
                elif item == 2:
                    colored_row += str(Fore.MAGENTA) + ' O ' + str(Style.RESET_ALL)
Reply


Messages In This Thread
RE: Type Error: bad operand type for unary +: 'str' - by ThomasL - Aug-12-2019, 05:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Sad [Solved] I'm not getting the good type slain 18 676 Apr-11-2024, 01:36 PM
Last Post: slain
Question How to get a removable disc type in drive Daring_T 12 1,277 Feb-11-2024, 08:55 AM
Last Post: Gribouillis
  all of attributes and methods related to a special type akbarza 4 491 Jan-19-2024, 01:11 PM
Last Post: perfringo
  Precision with Decimal Type charlesrkiss 9 751 Jan-18-2024, 06:30 PM
Last Post: charlesrkiss
  How to detect this type of images AtharvaZ 0 360 Jan-02-2024, 03:11 PM
Last Post: AtharvaZ
  problem with help(type(self)) in Idle akbarza 1 492 Dec-26-2023, 12:31 PM
Last Post: Gribouillis
  Static type checking with PyPy pitosalas 1 459 Dec-14-2023, 09:29 PM
Last Post: deanhystad
  How does sqlite3 module determine value type mirlos 2 949 Dec-12-2023, 09:37 AM
Last Post: mirlos
  mypy, type aliases and type variables tomciodev 1 715 Oct-18-2023, 10:08 AM
Last Post: Larz60+
  ValueError: Unknown label type: 'continuous-multioutput' hobbyist 7 1,312 Sep-13-2023, 05:41 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020