Btw there isn't much reason to deal which each dice separately just extract the number. If you want to restrict the dice types make an allowed list and check. You could do it like this.
Code:
import random
allowedDice=[4,6,8,10,12,20,100]
dice = input("choose dice:")
if dice[0] == "d":
size=int(dice[1:])
if(size in allowedDice):
result = random.randrange(1, size+1)
print("rolled ",dice," result=",result)
else:
print("Invalid size")
else:
print("Unrecognized command")
I didn't check whether what comes after d actually is a number though so int might give an exception if the input in wrong.
Instead of giving the allowed dice as numbers you could give it as "d4","d6".... and check the input directly, that would also prevent feeding anything into int that isn't an int. But numbers were less to type. (And unless you want to accept more commands than just dices I would only use the number as input.)