>From the documentation: "Input returns the expression it reads...". So, what
happens is that your variable <ans> is assigned <yes> (as a Mathematica
expression, Symbol in this case), not "yes" (as a String). So, the fix
would be to write
ans = ToString@Input["Would you like to play a game"];
Regards,
Leonid
On Sun, Jan 31, 2010 at 2:58 AM, Biff. Bartolemew <harrytuttle777 at mac.com>wrote:
> Hello,
>
> I hope someone can help me out, and not laugh to hard at my stupidity,
> but, I am trying write a little program
>
>
> playAGame[] := Module[
> {car},
> ans = Input["Would you like to play a game"];
> Print[ans];
> If[ans == "yes", Print["you answered yes"],
> Print["you did not answer yes"]
> ];
> If[5 == 5, Print["You suck"], Print["You Rock"]];
>
> ]
>
> The first If statement does not seem to be evaluated.
>
> Yet, if I type:
> "yes"=="yes", I get the answer I am looking for.
>
> It seems like the string comparison is acting different in the middle of
> the If statement. Can someone tell me what I am doing wrong?
>
>
> -Thanks
>
>