WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Converting a character to a number (https://forum.worldviz.com/showthread.php?t=2510)

jassel41 02-08-2010 08:40 PM

Converting a character to a number
 
I am currently trying to figure out how to retrieve a character from a text file and turn it to a number.

I currently split up the sentence and store the word I am interested in into an array, for example a spot in the array may look like the following:

['Interval=4;']

What I want to do is access the 4 and save its numeric value to a variable. If this is stored in array[1] for example, is there a way to access the 10th character, (the 4) and then convert it to a number?

Thank you,
Jassel41

JvdBosch 02-10-2010 07:37 AM

string = 'Interval=4'

string.split('=')[1] will return 4 (as string)
int(string.split('=')[1]) will return 4 (as int)
string[9] will return 4 (as string)
int(string[9]) will return 4 (as int)

And so on. Good luck!


All times are GMT -7. The time now is 11:40 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC