Skip to main content
1 of 3
AvahW
  • 543
  • 4
  • 7

#Python 3, 43 Bytes

n=int(input())
a='\\'*n
if n%2: a='/'*n
print(a)

In python the \ symbol is also used as an operator when inside a string (e.g: \n means newline) so \\ has to be used to get the backslash symbol.

This code works by assuming the input (n) is odd, and then checks if it is even. If so, then it redefines the variable a (the output) before displaying it.

This is shorter than using an if-else statement by 5 bytes as it does the checking after defining the variable, meaning that the else command is not needed.

AvahW
  • 543
  • 4
  • 7