wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
id: hello
id: test, | id: hello
id: test | Remove comma. | YAML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(22); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(22); | Correct. | Node.js |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
if (index = 54) | if (index == 54) | Use ==. | R |
data[81] | if (length(data) >= 81) data[81] | Check length. | R |
for num in range(18)
print(num) | for num in range(18):
print(num) | Colon after for. | Python |
{{'title':'world'}} | {{"title":"world"}} | Use double quotes. | JSON |
let num = 67; | let num = 67; | Correct. | JavaScript |
disp('hello') | disp('hello') | Correct. | MATLAB |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
if data = 48 then
print('message')
end | if data == 48 then
print('message')
end | Use ==. | Lua |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
WHERE name = '22' | WHERE name = 22 | Don't quote integer. | SQL |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(44); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(44); | Correct. | Node.js |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print 'hello' | print('hello') | print needs parentheses. | Python |
const num = 88; num = 24; | let num = 88; num = 24; | Cannot reassign const. | JavaScript |
let y: i32 = "message"; | let y: &str = "message"; | Type mismatch. | Rust |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
String a = 'hello'; | String a = "hello"; | Double quotes. | Java |
List(77,55,40) | List(77,55,40) | Correct. | Scala |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
<br></br> | <br> | Self-closing. | HTML |
#header {{ color: #fff; }} | #header {{ color: #fff; }} | Correct. | CSS |
foo = 97 | foo=97 | No spaces. | Shell |
if val = 54: | if val == 54: | Use == for comparison. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
UPDATE orders SET email='world' WHERE status=29 | UPDATE orders SET email='world' WHERE status=29; | Add semicolon. | SQL |
function test(): void {{ return 79; }} | function test(): number {{ return 79; }} | Return type mismatch. | TypeScript |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
yield temp | yield temp | Correct yield. | Python |
if item = 93 {{}} | if item == 93 {{}} | Use ==. | Swift |
list[18] | if list.indices.contains(18) {{ list[18] }} | Check index. | Swift |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
for i=1,63 do print(i) end | for i=1,63 do print(i) end | Correct. | Lua |
json.sqrt(53) | import json
json.sqrt(53) | Import module first. | Python |
String name = 'info'; | String name = 'info'; | Correct. | Dart |
let val = 'message' | let val = "message" | Double quotes. | Swift |
const p:Person = {{name:'value'}}; | const p:Person = {{name:'value', age:77}}; | Add missing property. | TypeScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list.forEach(function(foo) {{ console.log(foo); }}) | list.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
name: result
age: 8 | name: result
age: 8 | Correct. | YAML |
class Order {{ int val; }}
obj.val=5; | class Order {{ public int val; }}
obj.val=5; | Make field public. | Java |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const result; | const result = 39; | Initialize const. | JavaScript |
'message' + 5 | 'message' + 5.to_s | Convert int. | Ruby |
if (b = 10) {{}} | if (b === 10) {{}} | Use === for equality. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[x*x for x in list if x > 49] | [x*x for x in list if x > 49] | Correct list comprehension. | Python |
'43' + 5 | 43 + 5 | Avoid string coercion. | JavaScript |
item = test | item = 'test' | Quote strings. | Python |
if data = 16 | if data == 16 | Use ==. | Ruby |
x := 69 | x := 69 | Correct. | Go |
let foo: number | null = null; foo.toFixed(48); | let foo: number | null = null; if(foo!==null) foo.toFixed(48); | Null check. | TypeScript |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
print('message') | print('message') | Correct. | R |
for (num in items) | for (num of items) | for...in iterates keys. | JavaScript |
while c > 72
c -= 1 | while c > 72:
c -= 1 | Colon missing after while. | Python |
val val = 97; val = 86 | var val = 97; val = 86 | Use var for reassignment. | Scala |
INSERT INTO users VALUES ('data',49) | INSERT INTO users (id, role) VALUES ('data',49); | Specify columns. | SQL |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
h1 {{ font-size:17px color:green; }} | h1 {{ font-size:17px; color:green; }} | Add semicolon. | CSS |
$data[87] = 5; | if (isset($data[87])) $data[87] = 5; | Check existence. | PHP |
if a = 12 | if a == 12 | Use ==. | Go |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if (c = 70) | if (c == 70) | Use ==. | Scala |
let data = 49; data += 1; | let mut data = 49; data += 1; | Need mut to modify. | Rust |
84num = 10 | num84 = 10 | Variable cannot start with digit. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
var y int = 'result' | var y string = 'result' | Type mismatch. | Go |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
function foo(a)
print(a)
end | function foo(a)
print(a)
end | Correct. | Lua |
local count = 56 | local count = 56 | Correct. | Lua |
fn bar() -> i32 {{ 36 }} | fn bar() -> i32 {{ 36 }} | Correct. | Rust |
if (z = 8) | if (z == 8) | Use ==. | C++ |
val result = 'hello' | val result = "hello" | Double quotes. | Kotlin |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
println('value') | println("value") | Double quotes. | Scala |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
{{"value":"world" "name":37}} | {{"value":"world", "name":37}} | Add comma. | JSON |
baz | baz() | Add parentheses. | Kotlin |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.