Python Forum

Full Version: Print part of a variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hm, I want to print only 27 + a random generated number so it should be (for example) 2717. The content of variable meters should not be included, not sure how to do it.

lenght = meters + ", 27" + str(random.randint(0,50))
By removing meters from the statement.
Variable lenght is passed on to a function where meters is needed, in the function I will print variable lenght but without meters.
The answer remains same. meters and length are two different variables.
If function needs meters also, pass it as an additional argument.
Ok, thanks. Will test.