Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modify Input() text
#1
Hello!
strText = "this is text 1"
a = input()+strText #or something like this
print(a)
How can I make to appear strText as input text that can be modified? What I want is to modify some text in strText but i don't want to write the entire string from the beggining, i want to appear automatically the strText and to modify only some text inside.

I hope that you can understand me!
Thank you!
Reply
#2
catosp Wrote:I hope that you can understand me!
Sorry, I cannot. Please explain what you want to do. For example suppose that the user enters "spam". What effect do you expect from your code?
Reply
#3
I want to use strText as predefined input text which can be modified from keyboard before hit enter and to pass it to variable a.
Reply
#4
Maybe something like
strText = "this is text 1"
a = ', '.join((input('input something '), strText))
print(a)
Output:
input something something something, this is text 1
Reply
#5
@Yoriz. Not exactly!
Let suppose that you want to write from keyboard in console for the input() the following text: I love hamburger. But you dont want to write the same string again and again, sometimes you want to write:I hate hamburger. In that case instead of write I hate hamburger from keyboard, you want to appear in console the text I love hamburger, and navigate with your keyboard arrow to word love and delete it with backspace and replace it with the word hate.

Something like when you hit up arrow on cmd and call the last command, but instead of last command I want a specific predefined string, but which can be modified.
Reply
#6
Sound like you would be better off using a GUI with a text entry which can be pre-filled with anything you like.
Reply
#7
I think catosp is talking about something like command line retrieval that is supported by almost every command shell. And I have the ability to recall previous things I typed into a python script if I started that script from a shell. For example I rand a program from the Windows CMD shell:
Output:
C:\musings>python echo.py type something: I typed this I typed this type something: I typed this and used up arrow to recall "I typed this" I typed this and used up arrow to recall "I typed this"
If you are running a program from IDLE you can access the "input" history by typing alt+p. For other terminals in other IDE's I imagine there are similar ways to reduce typing.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,054 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  Read text file, modify it then write back Pavel_47 5 1,500 Feb-18-2023, 02:49 PM
Last Post: deanhystad
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,575 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Selecting text as an input lazerwolf101 2 2,207 May-29-2020, 06:52 AM
Last Post: lazerwolf101
  Python QGIS tool that replaces layout text labels with attributes from an input table geodenn92 1 2,629 Aug-13-2019, 06:05 AM
Last Post: buran
  Four text files input combinations into an output file mhyga 2 2,186 Jul-28-2019, 06:52 PM
Last Post: ThomasL
  removing tabs from input text jenya56 3 3,146 Mar-28-2019, 03:10 PM
Last Post: DeaD_EyE
  How to format text to modify itself for different console sizes. FWendeburg 0 1,569 Feb-18-2019, 06:43 PM
Last Post: FWendeburg
  How do I shorten my input options? - text adventure ShiningKnight 3 4,624 Jan-01-2017, 03:21 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020