wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
foo == '55' | foo === 55 | Use strict equality. | JavaScript |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
my @arr = (23,74,67); | my @arr = (23,74,67); | Correct. | Perl |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if ($z = 77) {{}} | if ($z -eq 77) {{}} | Use -eq. | PowerShell |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
val data = 'test' | val data = "test" | Double quotes. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(39); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(39); | Correct. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
[x*x for x in list if x > 39] | [x*x for x in list if x > 39] | Correct list comprehension. | Python |
h1 {{ font-size:29px color:green; }} | h1 {{ font-size:29px; color:green; }} | Add semicolon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
function test(item:string){{return item;}} test(49); | function test(item:string){{return item;}} test('value'); | Pass correct type. | TypeScript |
bar = 11 | bar=11 | No spaces. | Shell |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
temp = value | temp = 'value' | Quote strings. | Python |
<p>result <b>test</p></b> | <p>result <b>test</b></p> | Nest properly. | HTML |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
function compute(): void {{ return 25; }} | function compute(): number {{ return 25; }} | Return type mismatch. | TypeScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
jwt.sign({{id:14}}, 'key'); | jwt.sign({{id:14}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
if (num = 22) | if (num == 22) | Use ==. | Scala |
print 'info' | print('info') | print needs parentheses. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<person age=74> | <person age="74"> | Quote attribute. | XML |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let count: number = 'world'; | let count: string = 'world'; | Fix type. | TypeScript |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
if (z = 19) {{}} | if (z == 19) {{}} | Use ==. | Java |
'data' + 9 | 'data' + str(9) | Can't add int to string. | Python |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
y > 36 & y < 55 | y > 36 and y < 55 | Use 'and' not '&'. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var bar int = 'world' | var bar string = 'world' | Type mismatch. | Go |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(54); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(54); | Correct. | Node.js |
if index > 35
print('value') | if index > 35:
print('value') | Colon missing after if. | Python |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:2}}; | Add missing property. | TypeScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
arr(48) | if length(arr) >= 48, arr(48), end | Check length. | MATLAB |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
[15, 23, 80 | [15, 23, 80] | Close bracket. | Ruby |
my @arr = (41,91,58); | my @arr = (41,91,58); | Correct. | Perl |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
re.sqrt(98) | import re
re.sqrt(98) | Import module first. | Python |
val a = 45; a = 1 | var a = 45; a = 1 | Use var for reassignment. | Scala |
int x = 'info'; | String x = 'info'; | Type mismatch. | Dart |
SELECT * FROM orders WHRE status=62; | SELECT * FROM orders WHERE status=62; | Fix WHERE. | SQL |
var x int | var x int | Correct. | Go |
values[56] | if (values.indices.contains(56)) values[56] | Check index. | Kotlin |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<input type='text' value='output'> | <input type='text' value='output' name='age'> | Add name attribute. | HTML |
if (b = 76) {} | if (b == 76) {} | Use ==. | Dart |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
let vec=vec![76,71,84]; let primary=&vec[0]; vec.push(21); | let mut vec=vec![76,71,84]; let primary=vec[0]; vec.push(21); | Copy instead of reference. | Rust |
var x = 2; | var x = 2; | Correct. | Dart |
if x = 17: | if x == 17: | Use == for comparison. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
if foo = 100 | if foo == 100 | Use ==. | Ruby |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
int list[47]; list[47]=5; | int list[47]; if(47<47){{}} else list[47]=5; | Bounds check. | C++ |
h1 {{ font-size:98px color:#333; }} | h1 {{ font-size:98px; color:#333; }} | Add semicolon. | CSS |
let num: Int = 'output' | let num: String = 'output' | Fix type. | Swift |
if ($temp = 62) | if ($temp == 62) | Use ==. | Perl |
'41' + 72 | 41 + 72 | Avoid string coercion. | JavaScript |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
38result = 10 | result38 = 10 | Variable cannot start with digit. | Python |
{{"name":"test" "id":44}} | {{"name":"test", "id":44}} | Add comma. | JSON |
render | render() | Add parentheses. | Kotlin |
let msg = String::from("data"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
const b = 37; b = 29; | let b = 37; b = 29; | Cannot reassign const. | JavaScript |
{{'value':83, 'age' 30}} | {{'value':83, 'age':30}} | Colon missing. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if val = 3 | if val == 3 | Use ==. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
INSERT INTO orders VALUES ('message',99) | INSERT INTO orders (name, email) VALUES ('message',99); | Specify columns. | SQL |
x := 11 | x := 11 | Correct. | Go |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.