def text2railfence(text, key = 3): 
	"""
	Returns the encrypted text after encrypting the text with the given key

		Parameters:
			text (str): The text that needs to be encrypted in the Railfence cipher
			key (int): The Key that should be used to encrypt the text 

		Returns:
			encrypted (str): The encrypted text
	"""
	text = text.replace("\n", "")

	rail = [['\n' for i in range(len(text))] 
				  for j in range(key)] 
	  
	dir_down = False
	row, col = 0, 0
	  
	for i in range(len(text)): 
		  
 
		if (row == 0) or (row == key - 1): 
			dir_down = not dir_down 
		  

		rail[row][col] = text[i] 
		col += 1
		   
		if dir_down: 
			row += 1
		else: 
			row -= 1

	result = [] 
	for i in range(key): 
		for j in range(len(text)): 
			if rail[i][j] != '\n': 
				result.append(rail[i][j]) 
				
	encrypted = "".join(result) 
	return encrypted