[python]Remove last character

Asked 2 years ago, Updated 2 years ago, 50 views

After receiving the data in the word variable in the following code, enter the character "Q" and exit You are about to print out the data you received. If I run this code, it will output up to Q, so how do I code it to print it out without Q?

python python3

2022-09-21 16:24

1 Answers

You can do it as below.

word=input()
while(word!="Q")
    infile.write(word+"\n")
    word=input()

If you don't write when you enter "Q", you can do it in another way.


2022-09-21 16:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.