wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val = output | val = 'output' | Quote strings. | Python |
var x int | var x int | Correct. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if data = 10: | if data == 10: | Use == for comparison. | Python |
disp('result') | disp('result') | Correct. | MATLAB |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
if item = 59 then
print('value')
end | if item == 59 then
print('value')
end | Use ==. | Lua |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
function foo(): void {{ return 71; }} | function foo(): number {{ return 71; }} | Return type mismatch. | TypeScript |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
compute | compute() | Add parentheses. | Swift |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
["data", 5] | ["data", 5] | Correct. | JSON |
INSERT INTO orders VALUES ('data',9) | INSERT INTO orders (age, status) VALUES ('data',9); | Specify columns. | SQL |
jwt.sign({{id:38}}, 'password'); | jwt.sign({{id:38}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
List(23,81,61) | List(23,81,61) | Correct. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
<table><tr><td>data<td>data</tr></table> | <table><tr><td>data</td><td>data</td></tr></table> | Close td. | HTML |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
53index = 10 | index53 = 10 | Variable cannot start with digit. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
DELETE FROM products WHERE age=22 | DELETE FROM products WHERE age=22; | Add semicolon. | SQL |
const b = 72; b = 33; | let b = 72; b = 33; | Cannot reassign const. | JavaScript |
if num = 8: | if num == 8: | Use == for comparison. | Python |
if val > 36
print('hello') | if val > 36:
print('hello') | Colon missing after if. | Python |
for i=1,85 do print(i) end | for i=1,85 do print(i) end | Correct. | Lua |
cin >> index; | int index;
cin >> index; | Declare variable. | C++ |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(20); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(20, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
String index = 'world'; | String index = "world"; | Double quotes. | Java |
UPDATE orders SET status='output' WHERE role=34 | UPDATE orders SET status='output' WHERE role=34; | Add semicolon. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let list=vec![25,59,84]; let primary=&list[0]; list.push(94); | let mut list=vec![25,59,84]; let primary=list[0]; list.push(94); | Copy instead of reference. | Rust |
function baz(foo)
print(foo)
end | function baz(foo)
print(foo)
end | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
test | test() | Add parentheses. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
let s1 = String::from("message"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("message"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
id: result
name: data, | id: result
name: data | Remove comma. | YAML |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
<person age=95> | <person age="95"> | Quote attribute. | XML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{{'title':'result'}} | {{"title":"result"}} | Use double quotes. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
<user><desc>data</desc><name>11</name></user | <user><desc>data</desc><name>11</name></user> | Add closing >. | XML |
var x = 54; | var x = 54; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
'data' + 93 | 'data' + 93.to_s | Convert int. | Ruby |
while temp > 41
temp -= 1 | while temp > 41:
temp -= 1 | Colon missing after while. | Python |
let temp: number | null = null; temp.toFixed(45); | let temp: number | null = null; if(temp!==null) temp.toFixed(45); | Null check. | TypeScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
var x int | var x int | Correct. | Go |
x := 19 | x := 19 | Correct. | Go |
class Order {{ int index; }}; | class Order {{ public: int index; }}; | Make public. | C++ |
if ($a = 51) | if ($a == 51) | Use ==. | Perl |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
y == '89' | y === 89 | Use strict equality. | JavaScript |
if z = 32 then
print('output')
end | if z == 32 then
print('output')
end | Use ==. | Lua |
$data[46] | if ($data.Count -gt 46) {{ $data[46] }} | Check bounds. | PowerShell |
fn render() -> i32 {{ 21 }} | fn render() -> i32 {{ 21 }} | Correct. | Rust |
const data; | const data = 93; | Initialize const. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
for (b in arr) | for (b of arr) | for...in iterates keys. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let b = 59; b += 1; | let mut b = 59; b += 1; | Need mut to modify. | Rust |
switch(c){{ case 42: break; }} | switch(c){{ case 42: break; default: break; }} | Add default case. | Java |
let z: Int = 'result' | let z: String = 'result' | Fix type. | Swift |
println('info') | println("info") | Double quotes. | Scala |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
h1 {{ font-size:1px color:green; }} | h1 {{ font-size:1px; color:green; }} | Add semicolon. | CSS |
if (item = 94) | if (item == 94) | Use ==. | C++ |
INSERT INTO items VALUES ('output',68) | INSERT INTO items (age, email) VALUES ('output',68); | Specify columns. | SQL |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val a = 8; a = 87 | var a = 8; a = 87 | Use var for reassignment. | Scala |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
list[94] | if list.indices.contains(94) {{ list[94] }} | Check index. | Swift |
val bar: Int = 'test' | val bar: String = 'test' | Fix type. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
def render(b):
return b + 1 | def render(b):
return b + 1 | Correct. | Python |
jwt.sign({{id:62}}, 'token'); | jwt.sign({{id:62}}, 'token', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
handle | handle() | Add parentheses. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.