A
A
Andrey Godunko2021-08-07 09:42:15
Python
Andrey Godunko, 2021-08-07 09:42:15

How to fix TypeError: bad operand type for unary +: 'str'?

My code:

goal = str(input('Веди цель  >> '))
goal_1 = str(input('Веди цель  >> '))	
goal_2 = str(input('Веди цель  >> '))
goal_3 = str(input('Веди цель  >> '))

if goal_3 =='all':
  for i in range(3):
    a = print( f'1. {goal}' ) 
    b = print(  f'2. {goal_1}' )
    c = print( f'3. {goal_2}' )
    what = str(input('И так какую цель ты виполнил 1, 2, 3 ? >> '))

    if what == '1':
      os.system('cls||clear')# clean cmd
      a = + 'respect'

    elif what == '2':
      os.system('cls||clear')# clean cmd
      b = + '*respect'

    elif what == '3':
      os.system('cls||clear')# clean cmd
      c = + '*respect'

Mistake
Traceback (most recent call last):
File "D:\Python\a.py", line 17, in
a = + 'respect'
TypeError: bad operand type for unary +: 'str'

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Shevkunov, 2021-08-07
@Noy-name-boy

a = print(something) # a = None
a += text # None + text
cannot be added to None and str
# code must be inserted via code insertion

E
EgorSvinarev, 2021-08-07
@EgorSvinarev

a += respect

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question