Alec Solomon
Alec Solomon

Reputation: 13

'If' statement In python turtle

I am trying to figure out is how to make an if statement

a.circle(b*(36-[(if p =3 (p*3), -i*36)

What I want is if the P value is three or greater it causes the circle to subtract p3 from 36 but if P is not equal to three or more then I want for the code to say I do not want it to subtract p from 36.

I'm using python3.6 that I installed and run through terminal.

Upvotes: 1

Views: 2442

Answers (2)

Dayana
Dayana

Reputation: 1538

If you want to do a Python 'traditional' if:

if condition:
    ...
else:
    ...

in one line:

value_if_condition_is_true if condition else value_if_condition_is_false

In your case you could try:

p*3 if p >=3 else -i*36

I hope this help you!

Upvotes: 0

Reblochon Masque
Reblochon Masque

Reputation: 36662

Translating your request from English to code:

R = 36

# if the P value is three or greater 
if p >= 3:
    # it causes the circle to subtract p3 from 36 
    R -= p

# but if P is not equal to three or more 
else:
    # then I want for the code to say I do not want it to subtract p from 36.
    pass

a.circle(b * (R, -i * 36))   # attention, i is not defined

Upvotes: 2

Related Questions