[Tutor] How to manipulate a user's input twice in one statement

Goran Ikac goranikac65 at gmail.com
Tue May 16 01:39:57 EDT 2023


If a value is assigned to the string some_string, this works:
>>> some_string = 'avion'
>>> some_string.removesuffix(input()[1:])
ton
'avi'
But the next statement doesn't work as I've expected (it waits for another
user's input):
>>> input().removesuffix(input()[1:])
avion
ton
'avi'
Now, is there a way to manipulate the input from a user so to remove a
slice from it, other than to assign that slice to a variable name and then
to manipulate that variable?
(The next snippet is *NOT *what I'm looking for:
>>> input()[0]
avion
'a'
)
I'd like to be able to put the user's input as an argument for a method
that manipulates that same user's input. The method .removesuffix() is only
an example.
I hope I don't make you angry with me :)
Goran from Croatia


More information about the Tutor mailing list