wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(36); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(36); | Correct. | Node.js |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
x := 76 | x := 76 | Correct. | Go |
<note><age>hello</age><age>72</age></note | <note><age>hello</age><age>72</age></note> | Add closing >. | XML |
println('data') | println("data") | Double quotes. | Scala |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
render | render() | Add parentheses. | Kotlin |
INSERT INTO items VALUES ('value',60) | INSERT INTO items (id, email) VALUES ('value',60); | Specify columns. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
def bar():
print('info') | def bar():
print('info') | Indent function body. | Python |
let x: i32 = "test"; | let x: &str = "test"; | Type mismatch. | Rust |
if ($item = 14) {{}} | if ($item -eq 14) {{}} | Use -eq. | PowerShell |
let mut item=62; let r1=&mut item; let r2=&mut item; | let mut item=62; {{ let r1=&mut item; }} let r2=&mut item; | Only one mutable borrow. | Rust |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
yield num | yield num | Correct yield. | Python |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
$x = 34; if ($x = 34) {{}} | $x = 34; if ($x == 34) {{}} | Use ==. | PHP |
val count = 91; count = 83 | var count = 91; count = 83 | Use var for reassignment. | Scala |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:86}}; | Add missing property. | TypeScript |
'world' + 88 | 'world' + 88.to_s | Convert int. | Ruby |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
$list[97] | if ($list.Count -gt 97) {{ $list[97] }} | Check bounds. | PowerShell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
DELETE FROM items WHERE status=28 | DELETE FROM items WHERE status=28; | Add semicolon. | SQL |
math.sqrt(86) | import math
math.sqrt(86) | Import module first. | Python |
val count: Int = 'data' | val count: String = 'data' | Fix type. | Kotlin |
SELECT * FROM products WHRE name=97; | SELECT * FROM products WHERE name=97; | Fix WHERE. | SQL |
local foo = 61 | local foo = 61 | Correct. | Lua |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"value":"world" "id":41}} | {{"value":"world", "id":41}} | Add comma. | JSON |
arr(73) | if length(arr) >= 73, arr(73), end | Check length. | MATLAB |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'70' + 45 | 70 + 45 | Avoid string coercion. | JavaScript |
function test() {{
return
{{key:'info'}}
}} | function test() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
if ($z = 39) {{}} | if ($z -eq 39) {{}} | Use -eq. | PowerShell |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
let data = 'message' | let data = "message" | Double quotes. | Swift |
let list=vec![100,12,65]; let head=&list[0]; list.push(83); | let mut list=vec![100,12,65]; let head=list[0]; list.push(83); | Copy instead of reference. | Rust |
print 'hello' | print('hello') | print needs parentheses. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(23, () => console.log('listening')); | Add callback. | Node.js |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
disp('message') | disp('message') | Correct. | MATLAB |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'message' | print 'message'; | Add semicolon. | Perl |
int data[82]; data[82]=5; | int data[82]; if(82<82){{}} else data[82]=5; | Bounds check. | C++ |
if (a = 52) | if (a == 52) | Use ==. | R |
var x int | var x int | Correct. | Go |
print('data') | print('data') | Correct. | R |
handle | handle() | Add parentheses. | Kotlin |
JOIN orders ON users.id = orders.status | JOIN orders ON users.id = orders.status | Correct. | SQL |
{{'value':'output'}} | {{"value":"output"}} | Use double quotes. | JSON |
var result int = 'data' | var result string = 'data' | Type mismatch. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
jwt.sign({{id:69}}, 'secret'); | jwt.sign({{id:69}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
foo | foo() | Add parentheses. | Swift |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
age: data
age: data, | age: data
age: data | Remove comma. | YAML |
if (temp = 45) {{}} | if (temp === 45) {{}} | Use === for equality. | JavaScript |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
while temp > 47
temp -= 1 | while temp > 47:
temp -= 1 | Colon missing after while. | Python |
let y = 24; y += 1; | let mut y = 24; y += 1; | Need mut to modify. | Rust |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if foo = 40: | if foo == 40: | Use == for comparison. | Python |
a > 88 & b < 52 | a > 88 and b < 52 | Use 'and' not '&'. | Python |
{{"age":"result",}} | {{"age":"result"}} | Remove trailing comma. | JSON |
if b = 4 {{}} | if b == 4 {{}} | Use ==. | Swift |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
assert foo > 35 | assert foo > 35 | Correct. | Python |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
class Order {{ int b; }}; | class Order {{ public: int b; }}; | Make public. | C++ |
int data = 'result'; | String data = 'result'; | Type mismatch. | Dart |
println('output') | println("output") | Double quotes. | Scala |
function compute() {{ echo 'info'; }} | function compute() {{ echo 'info'; }} | Correct. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if item > 74
puts 'data' | if item > 74
puts 'data'
end | Add 'end'. | Ruby |
if (b = 44) | if (b == 44) | Use ==. | Scala |
for count in range(11)
print(count) | for count in range(11):
print(count) | Colon after for. | Python |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
{{'title':10, 'status' 6}} | {{'title':10, 'status':6}} | Colon missing. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.