Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Not directly possible because <a href="https://stackoverflow.com/questions/4869770/why-does-python-assignment-not-return-a-value">assignment doesn't return anything in python</a> but with a bit of hack if you really want.</p> <pre><code>def main(): def f(): nonlocal x x = input() return x x = '' print("Sin(" + f() + ")") </code></pre> <p>This example is an idea about how you can do it. Instead of <code>nonlocal</code> you can have other hacks like mutable objects passed directly to give you more control over where you want the value to be stored.</p> <p><strong>By mutable objects</strong></p> <p>As has been mentioned in comments it is not totally safe and you will need some changes before using this code. It is just meant as an example. Till it becomes clear what the OP actually wants I'll leave it as it is.</p> <pre><code>def main(): def f(x): x[0] = input() return x[0] x = [''] print("Sin(" + f(x) + ")") </code></pre> <p><strong>EDIT2 - Avoiding echo of newline like in case of input()</strong></p> <p>If you want to avoid newline to be echoed then you should see <a href="https://stackoverflow.com/questions/3523174/raw-input-in-python-without-pressing-enter">this</a>. Then make a function to build the desired input into a nonlocal(or global) variable as per your requirements. Here you'll have to do some hackery to define another character at which the variable will be built completelty. Then using the function call between two print statements should give you the desired behavior. The variable returned by the function will have to be printed explicitly as nothing will be echoed. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload