Is my solution wrong?
I can't find what is wrong with it. It runs fine but Khan doesn't like it.
I can't find what is wrong with it. It runs fine but Khan doesn't like it.
Hi there,
Can you please provide your code for this exercise? Without seeing your exact code it's hard to say what the issue might be here.
Thanks!
import random
import avatar
#Condition to draw Hair accessory
bow_position = random.randint(1,3)
if bow_position == 1:
bow_position = avatar.draw_bow()
avatar.draw_eyes("medium")
# Drawing The Nose
eye_type = random.randint(1,2)
if eye_type == 1:
eye_type = avatar.draw_nose("triangle")
else:
eye_type = avatar.draw_nose("button")
# Drawing The Mouth
mouth_type = random.randint(1,4)
if mouth_type == 1 or mouth_type == 2:
mouth_type = avatar.draw_mouth("smile")
elif mouth_type == 3:
mouth_type = avatar.draw_mouth("teeth")
else:
mouth_type = avatar.draw_mouth("neutral")
# Conditon to draw Bowtie
if bow_position == 2:
bow_position = avatar.draw_bow()
It keeps on saying my code is wrong but when I run it, it works correctly.
Hi Lans Tshala,
The issue with your code is on these lines:
bow_position = avatar.draw_bow()
bow_position = avatar.draw_bow()
The bow_position variable shouldn't be updated here within the if statements, you should just be calling avatar.draw_bow()
Here's a corrected version of your code:
import random
import avatar
# Condition to draw Hair accessory
bow_position = random.randint(1,3)
if bow_position == 1:
avatar.draw_bow()
avatar.draw_eyes("medium")
# Drawing The Nose
eye_type = random.randint(1,2)
if eye_type == 1:
eye_type = avatar.draw_nose("triangle")
else:
eye_type = avatar.draw_nose("button")
# Drawing The Mouth
mouth_type = random.randint(1,4)
if mouth_type == 1 or mouth_type == 2:
mouth_type = avatar.draw_mouth("smile")
elif mouth_type == 3:
mouth_type = avatar.draw_mouth("teeth")
else:
mouth_type = avatar.draw_mouth("neutral")
# Condition to draw Bowtie
if bow_position == 2:
avatar.draw_bow()
Iniciar sesión para dejar un comentario.