Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TreeMaker
-
Build a tree :)
#coding: utf-8 import console print('1 space is stub 2 spaces is branch 3 spaces is apple') for x in range(100): tb = raw_input(' ') if tb == ' ': console.set_color(0.50, 0.25, 0.00) print(' |') elif tb == ' ': console.set_color(0.50, 0.25, 0.00) print(' -|') elif tb == ' ': console.set_color(1.00, 0.00, 0.00) print('•-|')
-
I love it! Some enhancement ideas...
#coding: utf-8 import console, random tree_program = ' , , , , , , , , , , '.split(',') # tree_program = None # uncomment this line to let the user build their own tree def tree_maker(tb): if tb == ' ': console.set_color(0.50, 0.25, 0.00) print(' |') elif tb == ' ': console.set_color(0.50, 0.25, 0.00) print(random.choice([' -|', ' |-'])) elif tb == ' ': console.set_color(1.00, 0.00, 0.00) print(random.choice(['•-|', ' |-•'])) if tree_program: print('Drawing a tree from: {}.'.format(tree_program)) for x in tree_program: tree_maker(x) else: print('1 space is stub 2 spaces is branch 3 spaces is apple') for x in range(100): tree_maker(raw_input(' ')) console.set_color(0, 0, 0) # be kind to the next program and go back to black
-
Cool! It would be awesome to make achievements. I'm working on that now. Thanks!
-
How can I tell how many times the user has entered something? I tried making an
if statement
to try it but it didn't work -
Let's use a dictionary to keep track of how many times the user entered each value...
watcher_dict = {} # a new empty dict while True: user_data = raw_input() if not user_data: # enter no data to... break # end the loop tree_maker(user_data) # record the user_data into watcher_dict if user_data in watcher_dict: # if it is already in the dict watcher_dict[user_data] += 1 # then add 1 to it else: # if it is not yet in the dict watcher_dict[user_data] = 1 # then set it to 1 print('watcher_dict:', watcher_dict)
-
Ooohhhh cool this works