If you have only an integer in the conditional of an if statement, the if statement will run if and only if the integer is not equal to zero. You need to do

if num < 0:

not

if num:

But indeed, @user8145959 has a point. The number inputted is already a string. When you pass the input string to int_to_str, it gets automatically converted to an integer at the places where you try integer operations on it.

Edit: Automatic integer conversion works only in python 2, not python 3. My mistake.

Edit2: Actually I'm just wrong. Didn't realize input() did the conversion already.

Answer from xunatai on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › cannot use str() to convert an int to a string.
r/learnpython on Reddit: Cannot use str() to convert an int to a string.
January 18, 2022 -

Okay, so I had a crash course in Python a looooong time ago, and that's all the prior experience I have with it. I'm starting to dabble in it again, playing around with it to make a text-based game.

In this game, you have stats - Speed, Health, etc etc. Each of these is a number (an int).

I am trying to define a function names statdisplay() so that when I call on it, it prints out your stats. So, if you have a Speed of 1, and the max Speed you can increase that stat to is 5, one of the printed lines would be:

Speed: 1 / 5

This was my ORIGINAL code:

 print("\nHealth: " + healthstat + " / " + maxhealth)
 print("\nHunger: " + hungerstat + " / " + maxhunger)

 print("\nStalking Skill: " + stalkingstat + " / 5")
 print("\nHunting Skill: " + huntingstat + " / 5")

 print("\nSpeed: " + speedstat + " / 5")
 print("\nStrength: " + speedstat + " / 5")

But then I got the following error:

TypeError: can only concatenate str (not "int") to str

So I mentally facepalmed myself and looked up how to convert an int to a string, and I keep reading that you can use the str() function (I know there are other ways, but I'm taking baby steps here trying to jog my memory on how everything works before I go doing everything by what's deemed "most appropriate").

This is my NEW code with that in mind:

 print("\nHealth: " + str(healthstat) + " / " + maxhealth)
 print("\nHunger: " + str(hungerstat) + " / " + maxhunger)

 print("\nStalking Skill: " + str(stalkingstat) + " / 5")
 print("\nHunting Skill: " + str(huntingstat) + " / 5")

 print("\nSpeed: " + str(speedstat) + " / 5")
 print("\nStrength: " + str(speedstat) + " / 5")

...and yet I am still getting the following error:

TypeError: can only concatenate str (not "int") to str

I can't seem to figure out what's wrong. I do not have the str() function defined as anything else. str() also doesn't seem to come from any special libraries that I'd need to import, but maybe I'm wrong there (I tried to look it up)... the only import I currently have is "import random".

My only other thought is that maybe it's a Google Colab thing, as that's where I'm currently running my code since this wasn't anything serious and I tend to go between two different computers.

Any help would be much appreciated!

Edit: accidentally had the new code in both code boxes.

🌐
Quora
quora.com › How-do-you-convert-int-to-string-without-using-an-in-built-function-in-Python-3-Python-Python-3-x-development
How to convert int to string without using an in-built function in Python 3 (Python, Python 3.x, development) - Quora
Answer (1 of 4): The simple answer is you cannot convert an int to a string without using any builtin functions. You can dress it up so the function isn’t visible but there are still functions being called.
🌐
FavTutor
favtutor.com › blogs › int-to-string-python
4 Ways to Convert Int to String in Python | FavTutor
September 14, 2021 - Learn how to convert int to string in python in 4 different ways. Also, check out what are integers and strings in python.
🌐
Cmlabs
cmlabs.co › home › references › web-development › how-to-convert-int-to-string
How to Convert Int to String in Phyton with Examples
June 18, 2024 - In general, a string is regarded as a data type. It is frequently implemented as an array data structure consisting of words or bytes that uses character encoding to record a succession of components. There are various ways how to convert int to string in Python.
🌐
Unstop
unstop.com › home › blog › convert int to string in python (6 methods with examples)
Convert Int To String In Python (6 Methods With Examples)
April 11, 2024 - In this article, we will learn ... formatting, format() method, F-strings, positional formatting, __str__() method and chr() function with examples....
🌐
EyeHunts
tutorial.eyehunts.com › home › convert int to string python without str | example code
Convert int to string python without str | Example code
November 17, 2021 - Use the ordinal number of '0' plus the remainder to obtain the ordinal number of the remainder, and then convert it to string using the chr function. def int_to_string(i): string = '' while True: i, remainder = divmod(i, 10) string = chr(ord('0') ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-integer-to-string-in-python
Convert integer to string in Python - GeeksforGeeks
repr() function is usually used for debugging, as it gives a detailed string version of an object. While it also converts integers to strings, it’s not the most common method for simple integer-to-string conversion. ... Explanation: repr(n) returns a string '42'. It’s similar to str() but usually used for debugging.
Published   July 12, 2025
Find elsewhere
🌐
MakeUseOf
makeuseof.com › home › programming › 4 ways to convert an integer to a string in python
4 Ways to Convert an Integer to a String in Python
March 9, 2022 - To use positional formatting, use the "%s" % prefix in front of the number, and Python will do the rest. ... # The integer value Number = 100 # Convert the integer into a string using positional formatting Str_value = "%s" % Number # Print the ...
🌐
Javatpoint
javatpoint.com › how-to-convert-int-to-string-in-python
How to convert int to string in Python - Javatpoint
How to convert int to string in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, basics, data types, operators, etc.
🌐
SheCodes
shecodes.io › athena › 2142-converting-an-integer-to-string-in-python
[Python] - Converting an Integer to String in Python - | SheCodes
Learn how to convert an integer to a string in Python by using the `str()` function or casting the integer as a string.
🌐
Scaler
scaler.com › home › topics › how to convert int to string in python
How to Convert int to string in Python - Scaler Topics
May 12, 2024 - While programming in Python, we ... string. There are several methods to convert an integer into a string, like, str() function, using %s keyword, the .format() function, and f-strings....
🌐
W3Schools
w3schools.in › python › examples › convert-int-to-string
Python Program to Convert Int to String
Instead of %d, the %s format specifier can also be used, which tells Python to treat the formatted value as a string. Note that both of these methods work for any type of object, not just integers. You can use them to convert any object to a string as long as it has a string representation.
🌐
Python Principles
pythonprinciples.com › blog › converting-integer-to-string-in-python
Converting integer to string in Python – Python Principles
>>> name = "Bob" >>> age = 33 >>> print(name + " is " + str(age) + " years old") Bob is 33 years old · However it is much cleaner to use the .format() method on strings instead: >>> print("{name} is {age} years old".format(name=name, age=age)) Bob is 33 years old · It is even cleaner to use f-strings, a new feature in Python 3:
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-convert-data-types-in-python-3
How To Convert Data Types in Python 3 | DigitalOcean
August 20, 2021 - This Python 3 tutorial will guide you through converting data types including numbers, strings, tuples and lists, as well as provide examples to help familia…
🌐
Codecademy Forums
discuss.codecademy.com › frequently asked questions › python faq
Why doesn’t Python automatically convert the number to a string? - Python FAQ - Codecademy Forums
May 7, 2018 - Question Why doesn’t Python automatically convert the number to a string? Answer The answer becomes more clear as you learn to debug larger projects, and was carefully thought out when the language was being designed. In Python, and many other languages, the belief is that explicit is better ...
🌐
iO Flood
ioflood.com › blog › python-int-to-string-conversion-guide-with-examples
Python Int to String Conversion Guide (With Examples)
November 23, 2023 - In this example, the integer ‘123’ is converted to the string ‘123’ using the str() function. For more advanced methods, background, and tips and tricks, continue reading the rest of the article. ... One of the simplest ways to convert an integer to a string in Python is by leveraging ...