+ 2
Help me print a random number from a given range, and if it has a certain digit eg 5, then it shouldn't print it. Here's my work
Import random a = random.randint(1, 100) x = 5 if x = a: del x print (a)
2 Antworten
+ 4
a = str(random.randint(1, 100))
if not ("5" in a):
print("Number has no 5s")
+ 1
a = random.randint(1, 100)
x = a if str(5) not in str(a) else None
If x:
print(x)
The condition is never met if x = none (I.e it has digit 5)