PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, May 19, 2022

[FIXED] Why can I only insert a number and not a name?

 May 19, 2022     python, variables     No comments   

Issue

Hi I'm new to Python and I'm wondering why I was only able to put numbers and not actual names in this code. When I added name I ran into a SyntaxError.

my_age = 27
half_my_age = 13
greeting = Hi 
name = Max
greeting_with_name = Hi + Max

print("my_age + half_my_age + greeting + name + greeting_with_name")    

Solution

Name is a String (Combination of characters) not a number. To Store a string in a variable you need to use double quotes ("") or Single Quotes ('').

In Your Code I think you need to put you HI or name into String like this "HI" or "name" to run you code without any SyntaxError.

I Hope this will help you in your python journey.



Answered By - Yogesh
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing