How to remove last couple of lines in the text file with powershell

Advertisements I have a text file as follows Apple=1 Manggo=1 Appleandmanggobellongsto=Jimmy Apple=1 Manggo=1 Appleandmanggobellongsto=Dave Apple=1 Manggo=1 Appleandmanggobellongsto=Carlton I want to remove the last 3 lines and this is what I want to achieve: Apple=1 Manggo=1 Appleandmanggobellongsto=Jimmy Apple=1 Manggo=1 Appleandmanggobellongsto=Dave $File = c:\Text.txt get-content $File | select-object -skiplast 3 | set-contect $File but I dont get… Read More How to remove last couple of lines in the text file with powershell

Python Optimize multiple if-else based on truthy value

Advertisements I have following code in Python where based on a boolean flag I need to check a list count, wondering if there is a better way to code this in Python? If var_true: if len(something) > 0: logger.console (“Something found”) else: raise AssertionError(“something was not found”) If not var_true: if len(something) == 0: logger.console… Read More Python Optimize multiple if-else based on truthy value

Python functions not running correctly

Advertisements I’ve written this code to convert a string to uppercase and lowercase, however when I call my functions, it doesn’t run. # take the input for the string string = input("Enter any string: ") def string_upper(up): return up.upper() print("Uppercase Output: ", string_upper(string)) def string_lower(low): return low.lower() print("Lowercase Output: ", string.lower(string)) if __name__ == "__main__":… Read More Python functions not running correctly