Today we learned new stuff
How to reverse a word
s = input (‘type something’)
print (s [::-1])
How to scramble 2 words together
#1 gather the user input x = input('1') y = input('2') #2. figure out how long we should loop if (len(x)>len(y)): looplength = len(x) else : looplength = len(y) #3, we loop through the longest string for i in range(looplength): #3.1 we only print if we are not at end of the string if (i<len(x)): print (x[i]) if (i<len(y)): print (y[i])
This works because you have two strings and you can make the 1st letter of string x and string y and mash them together in this example I will use Bob and Hello so it will be BH oe bl l o
Notice how the last 2 letters do not have a pair it is because, Hello is 2 letters longer than Bob. If I do Hello and Python it will end up the outcome will be HP, ey, lt, lh, on. Now all have a pair this is made possible because the two words have the same amount of words.
Minecraft Python editing
Go to your Raspberry Pi Type:
#!/usr/bin/python # Import Minecraft Libraries import mcpi.minecraft as minecraft import mcpi.block as block
mc = minecraft.minecraft.create() # Get player position pPos = mc.player.getTilePos()
mc.postToChat (“API Test”)
# Change block