If was specified in the conditional statement.
local variable 'aa' referenced before assignment
There is an error when it says that.
Is there an error because aa="T"
is designated only when it is true and not designated when it is false?
Write several conditional sentences at the end
if aa=="T":
I put conditional sentences like this
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
def second_index(text: str, symbol: str) -> [int, None]:
"""
returns the second index of a symbol in a given text
"""
if symbol in text:
x = text.find(symbol)
if x == 0:
text = text[1:]
else:
text = text[0:x]+text[x+1:]
if symbol in text:
y = text.find(symbol)+1
else : y = none
return y
I did this, but the error UnboundLocalError: local variable 'y' referenced before assignment, second_index, 16 appears
python checkio
def second_index(text: str, symbol: str) -> [int, None]:
return text.find(symbol) + 1 or None
Is it something that you can't just think about simply like this?
926 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
579 Understanding How to Configure Google API Key
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
621 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.