assigning letters to numbers

A forum for general discussion of the Python programming language.

assigning letters to numbers

Postby doctterdre » Thu Sep 22, 2016 10:18 pm

Code: Select all
print("p q r")
for p in [0,1]:
    for q in [0,1]:
        for r in [0,1]:
            print(p,q,r)


So I have to create the output:
p q r
T T T
T T F
T F T
T F F
F T T
F T F
F F T
F F F

So basically the 0 has to be a "T" and the 1 has to be a "F"
How would I modify my code to do this? Thanks
doctterdre
 
Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm

Re: assigning letters to numbers

Postby micseydel » Thu Sep 22, 2016 10:25 pm

Usually F and 0 go together... Have you tried replacing 0 with "T" in your code?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
micseydel
 
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: assigning letters to numbers

Postby doctterdre » Thu Sep 22, 2016 10:31 pm

Yeah it says T and F are not defined
doctterdre
 
Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm

Re: assigning letters to numbers

Postby micseydel » Thu Sep 22, 2016 10:36 pm

Did you use quote (") characters like I did?
Due to the reasons discussed here we will be moving to python-forum.io on October 1, 2016.

This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.
User avatar
micseydel
 
Posts: 3000
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: assigning letters to numbers

Postby doctterdre » Thu Sep 22, 2016 10:39 pm

oh yep it worked lol silly mistake. Thank you for the help
doctterdre
 
Posts: 8
Joined: Thu Sep 22, 2016 9:44 pm


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 2 guests

cron