Ok so I spent some time making this. It uses the sus character ඞ, and many bad practices and annoying things so there you go. It’s a “Hello World!” program.
I had not heard of the walrus operator but that could be very useful. I may be able to use it to make programs even fewer bytes. It saves lines for sure.
# Normal Python
myVar = "Hello world!"
print(myVar)
myVar += " I code in Python."
print(myVar)
# Walrus
print((myVar := "Hello world!"))
myVar += " I code in Python"
print(myVar)
@SharkCoding Yes, actually, it’s very much an underused operator that not a lot of people know about. It was added after the 3.8 update.
It called “walrus” because the colon (:) are the eyes and the equal sign (=) is the tusks.
Here is how you can use it in a program:
a = [1, 2, 3, 4]
if (n := len(a)) > 3:
print(f"List is too long ({n} elements, expected <= 3)")
Walrus makes code so much more efficient and slightly less readable:
while (thing := input((name := "Who are you?\n"))).lower().title() not in ["Steve", "Phil", "Shrek"]:
thing = input(name)
# Rather than
name = "Who are you\n"
thing = input(name)
while thing.lower().title() not in ["Steve", "Phil", "Shrek"]:
thing = input(name)
# Now for the maddening part
while (t:=input((n:="Who are you?\n"))).lower().title() not in ["Steve", "Phil", "Shrek"]: t=input(n)
Unfortunately when people are given the power of walrus … they start ti think shifter is better. PERL people loved to out all in one line and the goal was small and impossible to read (old times were weird).