problem with Sorting from Array

S

shanti bhushan

Dear All,

funtion "textPosValue " will give me key ,type and pos values from the
arrays.
This an embedded application code .
I want to execute some thing when key ==0 && type ==0 please let me
know
where to put such code i am getting confused with it


def textPosValue(data):
str_arr1=[" 0",".@/:1","abc2",
"def3","ghi4",
"jkl5","mno6",
"pqrs7","tuv8",
"wxyz9" ]
str_arr2=[" 0",".@/:1","ABC2",
"DEF3","GHI4",
"JKL5","MNO6",
"PQRS7","TUV8",
"WXYZ9" ]
str_arr3=["0","1","2",
"3","4","5",
"6","7","8",
"9" ]
str_arr4=[" 0",".@/:1","?[] 2",
"!<> 3",",&\ 4",
"()~ 5","'{}` 6",
";$|^ 7","_#% 8",
"-*+=9" ]
str=[str_arr1,str_arr2,str_arr3,str_arr4]
k=1
first=0
SecPos=0
sts=0
try:
for first in range(4):
for SecPos in range(10):
# print "first,SecPos,str[first]
[Secpos]",first,SecPos,str[first][SecPos]
sts=str[first][SecPos].find(data)
# print sts
if (sts < 0):
continue
else:
k=0
break
if (k==0):
print sts
break


return first, SecPos, sts
except IndexError:
return -1,-1,-1


for ch in "43.88.79.132" :
type,key,Pos=textPosValue(ch)
for i in range(type):
cat,data=remote_keypress("green")
send_sircs(cat,data)
sleep(0.5)

for j in range(Pos+1):
if (key ==0 && type ==0) // i want
to execute some thing when , key ==0 && type ==0 , is it the right
position??
cat,data=remote_keypress("space")
send_sircs(cat,data)
sleep(0.5)
cat,data=remote_keypress("violet")
send_sircs(cat,data)
sleep(0.5)

cat,data=remote_keypress(key)
send_sircs(cat,data)
sleep(0.5)
sleep(0.5)
 
C

Chris Rebert

Dear All,

funtion "textPosValue " will give me key ,type and pos values from the
arrays.
This an embedded application code .
I want to execute some thing when key ==0 && type ==0 please let me
               if (key ==0 && type ==0)                                 // i want

The logical-AND operator in Python is spelled "and", not "&&" as in
C-like languages.
Also, comments start with a "#", not with "//" (though you probably
already know this and seem to have merely had a momentary lapse).

I can offer no definitive guidance as to where the conditional belongs
due to your code's purpose being rather opaque. I would hazard a guess
that it should go near where you change the values of `key` and `type`
(since the condition depends upon them) and outside of any nested loop
(since you mentioned nothing about repetition).

Cheers,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top