9 Answers
+ 5
Kevin Alvarado ,
can it also be like 548545xx or 548545xxxxxxx or 548xxxxxxxxxx ?
the question is, if the number of 'x' is always the same or does it vary?
+ 5
Kevin Alvarado ,
the count of digits that have to be created randomly, is marked with 'x' in your sample. in this case it is 5 digits. can this also be an other count like 2 or 6?
+ 2
how to solve the task:
since we use the random module, we have to import it. from the module we can use the choices() function, to create a number for each "x"
>>> for functions, methods and so on, use the python reference or use google <<<
see my hints to solve this task:
https://code.sololearn.com/cwxgtS8jHi59/?ref=app
+ 1
I don't fully understand what you're trying to do from the example, but I think you can try these examples:
https://datagy.io/JUMP_LINK__&&__python__&&__JUMP_LINK-random-number/
+ 1
It always vary
+ 1
Yes it also be like 5272828xx or 272727xxxx 282828xxxxxxxx
0
I want to make python replace some X with random numbers
example
548545XXXX
RESULT
5485451234
something like that
0
what came first to my mind is:
take an input string like '62727xxx'
for every character in this string do following: if character == 'x', replace it with a random digit
if character != 'x', pass
this will work if input string consists of digits and x'es only, nothing else - it doesn't check the input. if you wish to check input, you can do it many different ways
0
use the inbuilt functions
first split the string and replace the x with random() function defined in math and then jion the string again to get the output. check the syntax for using split and replace and jion methods in google...if u dont know.