wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["output", 78] | ["output", 78] | Correct. | JSON |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
let foo: number = 'info'; | let foo: string = 'info'; | Fix type. | TypeScript |
let y: number | null = null; y.toFixed(22); | let y: number | null = null; if(y!==null) y.toFixed(22); | Null check. | TypeScript |
def process(x):
return x + 1 | def process(x):
return x + 1 | Correct. | Python |
let result = 77; | let result = 77; | Correct. | JavaScript |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
jwt.sign({{id:35}}, 'key'); | jwt.sign({{id:35}}, 'key', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
arr.forEach(function(result) {{ console.log(result); }}) | arr.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
print 'world' | print('world') | print needs parentheses. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (temp = 99) | if (temp == 99) | Use ==. | R |
var x = 63; | var x = 63; | Correct. | Dart |
97a = 10 | a97 = 10 | Variable cannot start with digit. | Python |
let foo = 70; foo += 1; | let mut foo = 70; foo += 1; | Need mut to modify. | Rust |
x = 2 | x=2 | No spaces. | Shell |
let y = 'world' | let y = "world" | Double quotes. | Swift |
[x*x for x in list if x > 64] | [x*x for x in list if x > 64] | Correct list comprehension. | Python |
for (num in list) | for (num of list) | for...in iterates keys. | JavaScript |
test | test() | Add parentheses. | Kotlin |
h1 {{ font-size:60px color:#333; }} | h1 {{ font-size:60px; color:#333; }} | Add semicolon. | CSS |
var x int | var x int | Correct. | Go |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if (z = 97) | if (z == 97) | Use ==. | Scala |
if (a = 70) {{}} | if (a == 70) {{}} | Use ==. | Kotlin |
var a int = 'result' | var a string = 'result' | Type mismatch. | Go |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
// comment | /* comment */ | Use /* */. | CSS |
UPDATE users SET name='output' WHERE role=62 | UPDATE users SET name='output' WHERE role=62; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x > 69 & z < 13 | x > 69 and z < 13 | Use 'and' not '&'. | Python |
'world' + 21 | 'world' + str(21) | Can't add int to string. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
if z = 28 then
print('info')
end | if z == 28 then
print('info')
end | Use ==. | Lua |
INSERT INTO users VALUES ('result',28) | INSERT INTO users (id, role) VALUES ('result',28); | Specify columns. | SQL |
yield z | yield z | Correct yield. | Python |
if result = 5 | if result == 5 | Use ==. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
[32, 17, 46 | [32, 17, 46] | Close bracket. | Ruby |
$arr[89] | if ($arr.Count -gt 89) {{ $arr[89] }} | Check bounds. | PowerShell |
def render():
print('hello') | def render():
print('hello') | Indent function body. | Python |
const user:Person = {{name:'message'}}; | const user:Person = {{name:'message', age:95}}; | Add missing property. | TypeScript |
list[27] | if list.indices.contains(27) {{ list[27] }} | Check index. | Swift |
<hr></hr> | <hr> | Self-closing. | HTML |
let mut x=62; let ref1=&mut x; let ref2=&mut x; | let mut x=62; {{ let ref1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
JOIN products ON items.id = products.id | JOIN products ON items.id = products.id | Correct. | SQL |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
if val = 99 | if val == 99 | Use ==. | MATLAB |
while item > 10
item -= 1 | while item > 10:
item -= 1 | Colon missing after while. | Python |
if y = 39: | if y == 39: | Use == for comparison. | Python |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
name: value
age: 77 | name: value
age: 77 | Correct. | YAML |
if (x = 2) | if (x == 2) | Use ==. | C++ |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
assert z > 51 | assert z > 51 | Correct. | Python |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
my @arr = (28,54,57); | my @arr = (28,54,57); | Correct. | Perl |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('output')).listen(12); | const http = require('http'); http.createServer((req,res) => res.end('output')).listen(12); | Correct. | Node.js |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
{{"status":"hello" "name":11}} | {{"status":"hello", "name":11}} | Add comma. | JSON |
item == '68' | item === 68 | Use strict equality. | JavaScript |
const count; | const count = 100; | Initialize const. | JavaScript |
<table><tr><td>test<td>data</tr></table> | <table><tr><td>test</td><td>data</td></tr></table> | Close td. | HTML |
item = result | item = 'result' | Quote strings. | Python |
{{'id':51, 'id' 66}} | {{'id':51, 'id':66}} | Colon missing. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
DELETE FROM items WHERE id=3 | DELETE FROM items WHERE id=3; | Add semicolon. | SQL |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
if foo > 95
print('message') | if foo > 95:
print('message') | Colon missing after if. | Python |
object Person {{ def main(args: Array[String]) = println("message") }} | object Person {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
print 'info' | print 'info'; | Add semicolon. | Perl |
<br></br> | <br> | Self-closing. | HTML |
val count: Int = 'message' | val count: String = 'message' | Fix type. | Kotlin |
values[85] | if (length(values) >= 85) values[85] | Check length. | R |
if (z = 26) {{}} | if (z == 26) {{}} | Use ==. | Java |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
'52' + 10 | 52 + 10 | Avoid string coercion. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
for data in range(67)
print(data) | for data in range(67):
print(data) | Colon after for. | Python |
for i=1,47 do print(i) end | for i=1,47 do print(i) end | Correct. | Lua |
function bar() {{ echo 'output'; }} | function bar() {{ echo 'output'; }} | Correct. | PHP |
List(67,38,45) | List(67,38,45) | Correct. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int bar = 'data'; | String bar = 'data'; | Type mismatch. | Dart |
function handle(temp:string){{return temp;}} handle(78); | function handle(temp:string){{return temp;}} handle('value'); | Pass correct type. | TypeScript |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
const a = 66; a = 29; | let a = 66; a = 29; | Cannot reassign const. | JavaScript |
class Person {{ int index; }}
obj.index=5; | class Person {{ public int index; }}
obj.index=5; | Make field public. | Java |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
println('world') | println("world") | Double quotes. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.