We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

13 posts • Page 1 of 1
jjonesjths
Posts: 8
Joined: Thu Jan 02, 2020 7:31 pm

Turtle snowflakes

Tue Oct 21, 2025 11:11 pm

Hi,

I have followed code in the beginners guide book and doing Python and created a turtle snowflakes.

When I run the programme it does not draw a snowflake.

I don’t know how to upload the code to show you.

bensimmo
Posts: 8139
Joined: Sun Dec 28, 2014 3:02 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 6:25 am

You can copy and paste that code here, then use the Code tags (either typed or from the menu above the reply box.)
app.php/help/bbcode

jjonesjths
Posts: 8
Joined: Thu Jan 02, 2020 7:31 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 10:03 am

Hi,

Image 1 is the first part of the code followed by Image 2
Image 3 is when I run the programme.

Please help
Attachments
3884119A-29AB-4D53-9E5E-2CEE1169FA1F (1).JPG
Image 3 when I run it
3884119A-29AB-4D53-9E5E-2CEE1169FA1F (1).JPG (98.54 KiB) Viewed 805 times
03F623D9-AC9A-4437-BEB6-7CB268435247 (1).JPG
Image 2
03F623D9-AC9A-4437-BEB6-7CB268435247 (1).JPG (99.77 KiB) Viewed 805 times
CC96028A-5FD9-40EF-A15A-1E552EA0C614 (1).JPG
Image 1
CC96028A-5FD9-40EF-A15A-1E552EA0C614 (1).JPG (98.56 KiB) Viewed 805 times

B.Goode
Posts: 18780
Joined: Mon Sep 01, 2014 4:03 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 10:22 am

jjonesjths wrote:
Wed Oct 22, 2025 10:03 am

Please help


As already requested, it is so much easier for volunteer helpers to recreate your problem and investigate if you post the code you are using.

A screenshot means laborious re-typing. I for one will not do that.


An alternative might be to post a link to the particular book, guide or tutorial you are following.
Beware of the Leopard

rpiMike
Posts: 3636
Joined: Fri Aug 10, 2012 12:38 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 10:47 am

My guess based on your partial code images, why is pat.color(...) commented out?

ghp
Posts: 4448
Joined: Wed Jun 12, 2013 12:41 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 10:49 am

There are snowflakes around in the net

https://github.com/MissPhilbin/GeekGurl ... owflake.py
and an explanation video too
https://www.youtube.com/watch?v=DHmeX7YTHBY

The code looks different from what OP posted. But it runs in Thonny and creates a certain pre-winter mood.

bensimmo
Posts: 8139
Joined: Sun Dec 28, 2014 3:02 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 11:20 am

Un-indent lines 25-27, they are currently part of the function.

I'm assuming it should be the main program loop.

rpiMike
Posts: 3636
Joined: Fri Aug 10, 2012 12:38 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 11:30 am

bensimmo wrote:
Wed Oct 22, 2025 11:20 am
Un-indent lines 25-27, they are currently part of the function.

I'm assuming it should be the main program loop.
Don't think so, they draw the 8 branches of the snowflake.

B.Goode
Posts: 18780
Joined: Mon Sep 01, 2014 4:03 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 11:30 am

A further response, added after a little research.

It seems likely that you are following a Project published by the Code Club, a part of the Raspberry Pi FOUNDATION which is an education and research organisation separate from the company which runs these forums.

Ref: Turtle snowflakes - https://projects.raspberrypi.org/en/pro ... snowflakes


If that is the case, can you confirm that you have successfully completed all the preceding intermediate steps in the project, including 'Creating Spiral Patterns'?

Because if you have written and run the earlier examples it should be fairly simple to spot which part of your most recent changes has caused the altered program to not work as you expect. Note that the project authors themselves stress this -
Note: Remember that indentation is important. Make sure to check that all your indentation is correct, otherwise your code won’t work!
Beware of the Leopard

rpiMike
Posts: 3636
Joined: Fri Aug 10, 2012 12:38 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 11:59 am

rpiMike wrote:
Wed Oct 22, 2025 11:30 am
bensimmo wrote:
Wed Oct 22, 2025 11:20 am
Un-indent lines 25-27, they are currently part of the function.

I'm assuming it should be the main program loop.
Don't think so, they draw the 8 branches of the snowflake.
Actually, I think benisimmo is correct, this appears to be partial progress creating the snowflakes program.

I think the code should be:

Code: Select all

import turtle
import random
pat = turtle.Turtle()
turtle.Screen().bgcolor("grey")
colours = ["cyan", "purple", "white", "blue"]
pat.penup()
pat.forward(90)
pat.left(45)
pat.pendown()
def branch():
 for i in range(3):
 for i in range(3):
 pat.forward(30)
 pat.backward(30)
 pat.right(45)
 pat.left(90)
 pat.backward(30)
 pat.left(45)
 pat.right(90) 
 pat.forward(90)
for i in range(8):
 branch()
 pat.left(45)
Screenshot 2025年10月22日 at 12.58.51.png
Screenshot 2025年10月22日 at 12.58.51.png (116.09 KiB) Viewed 717 times

jjonesjths
Posts: 8
Joined: Thu Jan 02, 2020 7:31 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 3:14 pm

The book I am referring to is;

https://www.amazon.co.uk/Official-Raspb ... 108&sr=8-1

A beginners guide to Raspberry Pi by Gareth Halfacree.

I will have a look at it tomorrow

B.Goode
Posts: 18780
Joined: Mon Sep 01, 2014 4:03 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 3:43 pm

jjonesjths wrote:
Wed Oct 22, 2025 3:14 pm
The book I am referring to is;

https://www.amazon.co.uk/Official-Raspb ... 108&sr=8-1

A beginners guide to Raspberry Pi by Gareth Halfacree.

I will have a look at it tomorrow


On page #107, there is a section that says "Your finished program should look like this:"

I find it difficult to tell from your photos whether that is the case.


{Edit: added later - }
I can confirm that in my experiment the code published on that page ran as expected and produced a black snowflake on a grey background.
Last edited by B.Goode on Wed Oct 22, 2025 4:04 pm, edited 1 time in total.
Beware of the Leopard

bjepstone
Raspberry Pi Employee & Forum Moderator
Raspberry Pi Employee & Forum Moderator
Posts: 11
Joined: Mon Mar 06, 2023 2:06 pm

Re: Turtle snowflakes

Wed Oct 22, 2025 3:52 pm

I've just added examples for each stage of the project to the book's GitHub repository at https://github.com/raspberrypipress/off ... s-guide-5e. You can download it using git from the Terminal or you can click the Code button and download a zip file.

If you download the zip, please extract it somewhere in your home directory. If you decide to use git clone in the Terminal, it will download the files into your home directory unless you use cd to change directory before you run git clone.

Assuming you've extracted the files to a folder called official-raspberry-pi-beginners-guide-5e in your home directory, you can click the Load icon in Thonny, navigate to the official-raspberry-pi-beginners-guide-5e/en/code/ch05 folder and you should see five files showing various stages of the project. Please open each one, confirm that it runs OK, and then you can compare those versions to yours.

bensimmo and rpiMike are correct that the final lines should not be indented under the branch() function. That's because they are the only place where the branch() function is called, so it would not be invoked unless those lines are part of the main program.
Attachments
Screenshot 2025年10月22日 112541.png
Screenshot 2025年10月22日 112541.png (33.87 KiB) Viewed 655 times

13 posts • Page 1 of 1

Return to "Python"

AltStyle によって変換されたページ (->オリジナル) /