+ 2

generate with python. help me

hello guys I'm new and I'm learning python,I want to make a code that replaces X with random numbers example 5454545xxxxx result 545454548965 something like that, who can help me please

28th Jul 2022, 5:16 PM
Kevin Alvarado
9 Respostas
+ 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?
28th Jul 2022, 8:38 PM
Lothar
Lothar - avatar
+ 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?
28th Jul 2022, 7:58 PM
Lothar
Lothar - avatar
+ 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
30th Jul 2022, 5:15 PM
Lothar
Lothar - avatar
+ 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/
28th Jul 2022, 5:51 PM
Lisa
Lisa - avatar
+ 1
It always vary
30th Jul 2022, 2:07 AM
Kevin Alvarado
+ 1
Yes it also be like 5272828xx or 272727xxxx 282828xxxxxxxx
30th Jul 2022, 2:23 AM
Kevin Alvarado
0
I want to make python replace some X with random numbers example 548545XXXX RESULT 5485451234 something like that
28th Jul 2022, 8:15 PM
Kevin Alvarado
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
30th Jul 2022, 1:19 PM
Patrick
Patrick - avatar
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.
30th Jul 2022, 4:22 PM
Vamsi G
Vamsi G - avatar