Python Forum
msvcrt.getch prints twice inside loop
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
msvcrt.getch prints twice inside loop
#5
Great stuff!

BTW ReallyBigTeeth,
You can simplify your print statement below with:
print('loop', count)
(Jun-23-2018, 05:29 AM)ReallyBigTeeth Wrote: When I run:
import msvcrt

count = 0

while True:
    count += 1
    character = msvcrt.getch()
    
    print('loop ' + str(count))
    print(character, end='\n\n')
        
    if character == b'q':
        break
Reply


Messages In This Thread
RE: msvcrt.getch prints twice inside loop - by Tazlord - Sep-04-2018, 06:23 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Variable definitions inside loop / could be better? gugarciap 2 486 Jan-09-2024, 11:11 PM
Last Post: deanhystad
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,938 Nov-07-2023, 09:49 AM
Last Post: buran
  zfill prints extra et the end of a var tester_V 4 949 Mar-24-2023, 06:59 PM
Last Post: tester_V
  Help adding a loop inside a loop Extra 31 4,804 Oct-23-2022, 12:16 AM
Last Post: Extra
  variable prints without being declared. ClockPillow 2 1,848 Jul-11-2021, 12:13 AM
Last Post: ClockPillow
  Adding to the dictionary inside the for-loop - weird behaviour InputOutput007 5 2,786 Jan-21-2021, 02:21 PM
Last Post: InputOutput007
  why print('\n') produced 2 new lines instead of 1 - Located inside a FOR loop JulyFire 2 2,584 Jan-10-2021, 01:50 AM
Last Post: JulyFire
  Output prints Account.id at the end? LastStopDEVS 5 2,869 Dec-19-2020, 05:59 AM
Last Post: buran
  Try/Exept prints only ones tester_V 11 3,975 Nov-03-2020, 02:38 AM
Last Post: tester_V
  Creating a variables inside FOR loop zazas321 5 4,163 Sep-16-2020, 04:42 PM
Last Post: Naheed

Forum Jump:

User Panel Messages

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