Popup with number does not work --- use str(number) or the % operator

Asked by KingRider

count=0
while True:
    count=count+1
 popup (count)
 if count = 10:
    break
pass

or

count=0 # contagem
while count<4:
    count=count+1
    popup (count)
pass

---------------------------------------------------------

Not work command popup() to output variable "count" .. how to make save count to popup output?

Thanks

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

none of these are real Python ;-)

pass is only needed, to have something correctly indented after if/elif/else/for/while/with, if no other statement would be there otherwise. But any way, it never does any harm ;-)

a counting loop:

for count in range(10):
   popup(str(count))

see more on loops: faq 1437

count is an integer and popup() wants a string, so it has to be converted e.g. with str(count)

another more comfortable option to embed formatted numbers and other objects into a string is with the % operator:

popup( "count is now: %d (and still counting)"%(count) )

see the % operator: http://docs.python.org/library/stdtypes.html#string-formatting-operations

Revision history for this message
KingRider (kingrider) said :
#2

Hum i see Python and command FOR

I like use command while =(

Thanks... good basic!

Can you help with this problem?

Provide an answer of your own, or ask KingRider for more information if necessary.

To post a message you must log in.