I’m relatively new to Python. What I try to do is convert this comprehensive list to a normal if, else statement.
def draw(self): self.value = choice(green_chars) self.y = self.y + self.speed if self.y < 1080 else -40 * randrange(1, 5) screen.blit(self.value, (self.x, self.y))
So far I’ve tried this:
self.value = choice(green_chars) if self.y < 1080: self.y = self.y + self.speed else: -40 * randrange(1, 5) screen.blit(self.value, (self.x, self.y))
But it doesn’t work.
Advertisement
Answer
You probably forgot to assign the value:
self.value = choice(green_chars) if self.y < 1080: self.y = self.y + self.speed else: self.y = -40 * randrange(1, 5) # Here screen.blit(self.value, (self.x, self.y))