Python Forum
Need help making code more efficient
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help making code more efficient
#6
finished getting the code to work. adjusted for the fact that having another def... in my code causes problems.
solution here:
character = 0
cur_str = []
my_string = "this is a test."
def setup():
    size(400, 400)
    
def draw():
    global character
    global cur_str
    global my_string
    frameRate(15)#again, added for exaggerated effect
    if character < len(my_string):
        cur_str.append(my_string[character])
        text(''.join(map(str, cur_str)), 10, 30)
        character = character + 1
for those wishing to keep the text on screen after the sentence has typed, add:
else:
        textSize(32)
        text(''.join(map(str, cur_str)), 10, 30)
to the end of the code
Reply


Messages In This Thread
Need help making code more efficient - by dhbergen - Apr-12-2018, 03:38 AM
RE: Need help making code more efficient - by dhbergen - Apr-17-2018, 01:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A more efficient code titanif 2 579 Oct-17-2023, 02:07 PM
Last Post: deanhystad
  Cleaning my code to make it more efficient BSDevo 13 1,648 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Making a function more efficient CatorCanulis 9 2,091 Oct-06-2022, 07:47 AM
Last Post: DPaul
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 1,915 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
Star I was making code for collision for my character izmamonke 2 2,176 Aug-06-2021, 04:30 PM
Last Post: izmamonke
  Making a code.py file to function, does not run hobbyist 6 3,062 Jan-27-2021, 07:50 AM
Last Post: DeaD_EyE
  Making new lines of code AvioxyYT 1 1,885 Jan-22-2021, 07:02 PM
Last Post: buran
  I there a more efficient way of printing ? Capitaine_Flam 7 3,704 Dec-01-2020, 10:37 AM
Last Post: buran
  Simple problem. looking for an efficient way silverchicken24 3 2,447 Oct-14-2019, 07:13 PM
Last Post: Larz60+
  making the code easier, list comprehension go127a 2 2,140 May-26-2019, 06:19 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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