1

I'm using QPython3 on my Android, but I have no idea how to intent code.

I have tried using

d.startActivity('android.intent.action.MAIN')

But I might be implementing it wrong.

My code right now:

question = input("Say a number: ")
answer = int(questioned) % 2 
a = 1
if int(answer) < 1:
d.startActivity('android.intent.action.MAIN'
print("even")
else
d.startActivity('android.intent.action.MAIN'
print("odd")

Error message:

line 5 d.startActivity('android.intent.action.MAIN' ^ IndentationError: expected an indented block 1|dreamlte:/ $

(The intents you see appeared when I but the code in Stack.)

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
user11119833
  • 17
  • 1
  • 3
  • You're missing closing parenthesis after `startActivity(...`. You should have `d.startActivity('android.intent.action.MAIN') print("...")` instead of `d.startActivity('android.intent.action.MAIN' print("...")`. – prubini87 Dec 30 '21 at 08:30
  • Your code is also not in**d**ented correctly. You need to fix your indentation, with a "d" not a "t". You're misreading your error message, perhaps? – prubini87 Dec 30 '21 at 08:33

1 Answers1

0

Python relies on indenting to define scope.
So code in the branches of your if-else needs to be indented.

question = input("Say a number: ")
answer = int(questioned) % 2 
a = 1

if int(answer) < 1:
    d.startActivity('android.intent.action.MAIN')
    print("even")
else:
    d.startActivity('android.intent.action.MAIN')
    print("odd")
TimothyP
  • 21,178
  • 26
  • 94
  • 142