# Input stdlib function

**URL:** <https://forum.modular.com/t/input-stdlib-function/115>\
**Category:** Mojo\
**Created:** [December 9, 2024, 8:27pm UTC](https://forum.modular.com/t/input-stdlib-function/115 "2024-12-09T20:27:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zbornak](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/zbornak/32/46_2.png) [@Zbornak](https://forum.modular.com/u/Zbornak)\
**Post date:** [December 9, 2024, 8:27pm UTC](https://forum.modular.com/t/input-stdlib-function/115/1 "2024-12-09T20:27:06Z")

</div>

Is anyone else having trouble with segfaults when using Mojo’s input function? I’m on apple silicon.

---

<div class="post-metadata">

**Author:** ![lesoup-mxd](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/lesoup-mxd/32/585_2.png) [@lesoup-mxd](https://forum.modular.com/u/lesoup-mxd)\
**Post date:** [December 9, 2024, 8:28pm UTC](https://forum.modular.com/t/input-stdlib-function/115/2 "2024-12-09T20:28:13Z")

</div>

Please explain in detail on how to reproduce the issue. If possible, please share a snippet of your code)

---

<div class="post-metadata">

**Author:** ![Zbornak](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/zbornak/32/46_2.png) [@Zbornak](https://forum.modular.com/u/Zbornak)\
**Post date:** [December 9, 2024, 8:38pm UTC](https://forum.modular.com/t/input-stdlib-function/115/3 "2024-12-09T20:38:55Z")

</div>

Hi there, many thanks for the quick responseI have an input function:

```
fn get_input(self) raises -> String:
    while True:
        var input_str = str(Python.evaluate("input()"))
        input_str = input_str.lower()
        
        if input_str == "exit":
            print("exiting the game, hamba kahle")
            exit(0)
        elif input_str == "rules":
            print_rules()
            print("enter your move:")
        else:
            return input_str

```

I have just changed it to a the mojo input function and it now seems to be working correctly.

var input\_str = input("make a choice: ")

Sorry about that. Do you know if someone has made any fixes to it?

---

<div class="post-metadata">

**Author:** ![lesoup-mxd](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/lesoup-mxd/32/585_2.png) [@lesoup-mxd](https://forum.modular.com/u/lesoup-mxd)\
**Post date:** [December 9, 2024, 8:40pm UTC](https://forum.modular.com/t/input-stdlib-function/115/4 "2024-12-09T20:40:47Z")

</div>

Regarding the python function? Well, it does get runtimed, and not all io features are supported just yet afaik

---

<div class="post-metadata">

**Author:** ![Zbornak](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/zbornak/32/46_2.png) [@Zbornak](https://forum.modular.com/u/Zbornak)\
**Post date:** [December 9, 2024, 9:18pm UTC](https://forum.modular.com/t/input-stdlib-function/115/5 "2024-12-09T21:18:20Z")

</div>

Yes I have tried it in a few exercises and I always got this “malloc: \*\*\* error for object 0x10d124008: pointer being realloc’d was not allocated” error but now I can’t recreate it.

---

<div class="post-metadata">

**Author:** ![lesoup-mxd](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/lesoup-mxd/32/585_2.png) [@lesoup-mxd](https://forum.modular.com/u/lesoup-mxd)\
**Post date:** [December 9, 2024, 9:20pm UTC](https://forum.modular.com/t/input-stdlib-function/115/6 "2024-12-09T21:20:37Z")

</div>

Well, mojo will change it’s memory allocation logic, maybe get a bit more parsable soon, we’ll wait and recreate

---

<div class="post-metadata">

**Author:** ![Zbornak](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/zbornak/32/46_2.png) [@Zbornak](https://forum.modular.com/u/Zbornak)\
**Post date:** [December 9, 2024, 9:24pm UTC](https://forum.modular.com/t/input-stdlib-function/115/7 "2024-12-09T21:24:41Z")

</div>

Many thanks for your input. If I get any problems I will let you know what error/s have occurred

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [June 7, 2025, 9:25pm UTC](https://forum.modular.com/t/input-stdlib-function/115/8 "2025-06-07T21:25:22Z")

</div>

Closed on June 7, 2025, 9:25pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
