Lucky Direction

ABC 391

Problem 25 of 50

Easy

What to do

Given a compass direction as a string (like 'N', 'SE', 'NW'), return the opposite direction. Swap N↔S and E↔W. For example, 'SE' → 'NW', 'N' → 'S'.

Key Concepts

if-statements string manipulation input and output

Examples

Input: direction = 'N'

Output: S

Input: direction = 'SE'

Output: NW

Tips for Beginners

  • Focus on understanding the logic, not memorizing syntax
  • Use print statements to debug your code
  • Don't worry about input parsing - the function handles that for you
  • If stuck, try writing out your solution on paper first

Python Editor

Loading Python...