The value of your variable must be a string in this case:
var1 = '2333'
if '4' in var1:
print('found it')
else:
newVariable = var1 + '4'
print(newVariable)
More Related Contents:
- How to handle special cases in my Python code?
- How to select random key with common values?
- max() functions with string argument
- UnicodeDecodeError: ‘charmap’ codec can’t decode byte X in position Y: character maps to
- Unpacking, extended unpacking and nested extended unpacking
- Local variable referenced before assignment?
- Deep copy of a dict in python
- Difference between except: and except Exception as e:
- What is the naming convention in Python for variable and function?
- Generic[T] base class – how to get type of T from within instance?
- floating point in python gives a wrong answer [duplicate]
- Function chaining in Python
- portable way to write csv file in python 2 or python 3
- Selenium gives “selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary” on Mac
- I have a high-performant function written in Julia, how can I use it from Python?
- Can someone explain this: 0.2 + 0.1 = 0.30000000000000004? [duplicate]
- Checking for NaN presence in a container
- Call a function defined in another function
- How to run a http server which serves a specific path?
- Python map object is not subscriptable [duplicate]
- Changing User Agent in Python 3 for urrlib.request.urlopen
- Print without b’ prefix for bytes in Python 3
- How to fix “no module named ‘app_one'”
- Hex string to signed int in Python
- Python 3 bytes formatting
- How to force Sphinx to use Python 3.x interpreter
- sys.stdin.readline() and input(): which one is faster when reading lines of input, and why?
- exec() not working inside function python3.x
- Weird MRO result when inheriting directly from typing.NamedTuple
- How to combine Celery with asyncio?