Issue
I want results between 1-50 using python mathematically.
My code has a string of different characters every time.
I have to take a length and do some math so that results always comes between 1-50.
Currently, I am doing the same but only for 1-10.
my code looks like below:-
ans= 0
sum = 0
char=update1['headline'] # this is dynamic random char string
sum=len(char)
ans= (sum % 10) + 1
print(ans)
How do I achieve that?
Solution
Just change ans= (sum % 10) + 1
to ans= (sum % 50) + 1
Answered By - Ayush Rawal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.