this post was submitted on 04 Sep 2024
7 points (100.0% liked)
Python
6400 readers
8 users here now
Welcome to the Python community on the programming.dev Lemmy instance!
๐ Events
Past
November 2023
- PyCon Ireland 2023, 11-12th
- PyData Tel Aviv 2023 14th
October 2023
- PyConES Canarias 2023, 6-8th
- DjangoCon US 2023, 16-20th (!django ๐ฌ)
July 2023
- PyDelhi Meetup, 2nd
- PyCon Israel, 4-5th
- DFW Pythoneers, 6th
- Django Girls Abraka, 6-7th
- SciPy 2023 10-16th, Austin
- IndyPy, 11th
- Leipzig Python User Group, 11th
- Austin Python, 12th
- EuroPython 2023, 17-23rd
- Austin Python: Evening of Coding, 18th
- PyHEP.dev 2023 - "Python in HEP" Developer's Workshop, 25th
August 2023
- PyLadies Dublin, 15th
- EuroSciPy 2023, 14-18th
September 2023
- PyData Amsterdam, 14-16th
- PyCon UK, 22nd - 25th
๐ Python project:
- Python
- Documentation
- News & Blog
- Python Planet blog aggregator
๐ Python Community:
- #python IRC for general questions
- #python-dev IRC for CPython developers
- PySlackers Slack channel
- Python Discord server
- Python Weekly newsletters
- Mailing lists
- Forum
โจ Python Ecosystem:
๐ Fediverse
Communities
- #python on Mastodon
- c/django on programming.dev
- c/pythorhead on lemmy.dbzer0.com
Projects
- Pythรถrhead: a Python library for interacting with Lemmy
- Plemmy: a Python package for accessing the Lemmy API
- pylemmy pylemmy enables simple access to Lemmy's API with Python
- mastodon.py, a Python wrapper for the Mastodon API
Feeds
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I think I understand where you get confused. The returned value of the
input
function is always a string, you have to convert it into a number before using it in calculation. Otherwise the auto-parser will convert everything into string. Even if you use*
or**
.But I thought the "value" doesn't exist until the end-user types in the value, due to the use of
input()
. So it starts off as a string, then becomes whatever is typed in, which then gets filtered through the next line. So if I type3
, it'll be considered as an integer, and likewise as a float if I type3.00
.the signature for the
input
function (that's what it's called instead of command) iswhich means it's always going to return a string.
there's no real way for something to do that automatically without a much more robust setup.
this snippet proves that
it is the responsibility of your program to validate and do whatever you want with the result, and part of that can include casting it to a different type.
Oh, I think I understand now.
Thank you for clarifying that to me!
No problem bud, good luck