The format string method is intended for this kind of task:

return 'salad: {} hamburger: {} water: {}'.format(s, h, w)

Unrelated: Your counting code is fragile. It happens to work correctly with this data set, because the letters shw only appear once each in the entire set of words. However, if you added a word like 'milkshake' this code would count an extra s and h every time it appeared.

A better way would be to split the string into words, then look at the first letter of each:

for word in order.split():
    char = word[0]
    if char == 's':
    etc.

Even more robust would be to count the words themselves and return a dict, but I’ll leave that to you when you get to dicts; it looks like you’re just beginning with Python.

Answer from Tom Zych on Stack Overflow
🌐
Career Karma
careerkarma.com › blog › python › python string to int() and int to string tutorial: type conversion in python
Python String to Int() and Int to String Tutorial: Type Conversion in Python
December 1, 2023 - How to Convert Python String to Int: To convert a string to integer in Python, use the int() function. This function takes two parameters: the initial string and the optional base to represent the data.
🌐
Real Python
realpython.com › convert-python-string-to-int
How to Convert a Python String to int – Real Python
January 16, 2021 - If you have a decimal integer represented as a string and you want to convert the Python string to an int, then you just pass the string to int(), which returns a decimal integer:
🌐
DigitalOcean
digitalocean.com › community › tutorials › python-concatenate-string-and-int
How to Concatenate String and Int in Python (With Examples) | DigitalOcean
May 2, 2025 - Learn how to combine strings and integers in Python using +, f-strings, str(), and more. Avoid common TypeErrors with these simple examples.
🌐
DataCamp
datacamp.com › tutorial › how-to-convert-a-string-into-an-integer-in-python
How to Convert a String Into an Integer in Python | DataCamp
November 24, 2024 - # Summing two numbers that are ... for calculations or other numerical operations. Python provides a straightforward way to achieve this using the int() function. This function takes a string as input and returns its integer representation, provided the string represents ...
🌐
Programiz
programiz.com › python-programming › methods › built-in › int
Python int() (With Examples)
# converting a string (that is ... a number, we can still convert it to an integer object. We can do this easily by overriding __index__() and __int__() methods of the class to return a number. The two methods are identical. The newer version of Python uses the __index__() ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-integer-to-string-in-python
Convert integer to string in Python - GeeksforGeeks
In this article, we’ll explore different methods for converting an integer to a string in Python. The most straightforward approach is using the str() function. str() function is the simplest and most commonly used method to convert an integer ...
Published   July 12, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-string-to-integer-in-python
Convert String to Int in Python - GeeksforGeeks
The simplest way to convert a string to an integer in Python is by using the int() function. This function attempts to parse the entire string as a base-10 integer. ... Explanation: The int() function takes the string s and converts it into ...
Published   September 11, 2025
🌐
Python Principles
pythonprinciples.com › blog › converting-integer-to-string-in-python
Converting integer to string in Python – Python Principles
To convert an integer to a string, use the str() built-in function. The function takes an integer (or other type) as its input and produces a string as its output.
🌐
Finxter
blog.finxter.com › home › learn python blog › python return integer from function
Python Return Integer From Function - Be on the Right Side of Change
October 24, 2022 - Put the result behind the return keyword (e.g., return 42). 👉 Recommended Tutorial: The return keyword in Python · Python’s int() function takes an argument such as a string or a float and converts it to an integer.
🌐
freeCodeCamp
freecodecamp.org › news › python-convert-string-to-int-how-to-cast-a-string-in-python
Python Convert String to Int – How to Cast a String in Python
November 29, 2021 - To convert, or cast, a string to an integer in Python, you use the int() built-in function. The function takes in as a parameter the initial string you want to convert, and returns the integer equivalent of the value you passed.
🌐
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.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-convert-strings-into-integers-in-python
How to Convert Strings into Integers in Python
January 16, 2020 - Similar to the built-in str() method, Python also offers the handy int() method that takes a string object as an argument and returns an integer. Example Usage: # Here age is a string object age = "18" print(age) # Converting a string to an ...
🌐
Igmguru
igmguru.com › blog › convert-string-to-int-in-python
How to Convert a Python String to int: Step by Step Guide (2026)
1 week ago - Learn how to convert a Python string to int using the int() function. A Step-by-step guide with examples, and safe methods like try-except and isdigit().
🌐
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 - Let’s first look at converting integers. To convert the integer 12 to a string value, you can pass 12 into the str() method: ... When running str(12) in the Python interactive shell with the python command in a terminal window, you’ll receive the following output: