I'm really new to Python and programming in general, so I've been stuck for a while trying to figure out through searching the internet how to print a string to a length determined by a variable. This is one of the things I tried, for an example of what I'm attempting to do:
var1 = 6 string1 = "a random string" print(string1[0,var1]) So I've been wondering if it is possible to use the stored value of a variable as a string indice or if there is another workaround that I haven't thought of or found on the rest of the internet.
Thanks for reading! :)
print(string1[0 : var1])You should use:instead of,