wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
DELETE FROM items WHERE id=81 | DELETE FROM items WHERE id=81; | Add semicolon. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
function process() {{ echo 'result'; }} | function process() {{ echo 'result'; }} | Correct. | PHP |
if b = 81 | if b == 81 | Use ==. | MATLAB |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
int a = 'value'; | String a = 'value'; | Type mismatch. | Dart |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
'17' + 50 | 17 + 50 | Avoid string coercion. | JavaScript |
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 |
44a = 10 | a44 = 10 | Variable cannot start with digit. | Python |
var b int = 'output' | var b string = 'output' | Type mismatch. | Go |
[x*x for x in arr if x > 30] | [x*x for x in arr if x > 30] | Correct list comprehension. | Python |
b > 99 & y < 89 | b > 99 and y < 89 | Use 'and' not '&'. | Python |
print('output') | print('output') | Correct. | R |
disp('world') | disp('world') | Correct. | MATLAB |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
println('hello') | println("hello") | Double quotes. | Scala |
print 'test' | print 'test'; | Add semicolon. | Perl |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(37); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(37, () => console.log('listening')); | Add callback. | Node.js |
h1 {{ font-size:90px color:#333; }} | h1 {{ font-size:90px; color:#333; }} | Add semicolon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
var x int | var x int | Correct. | Go |
'info' + 10 | 'info' + 10.to_s | Convert int. | Ruby |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
while x > 46
x -= 1 | while x > 46:
x -= 1 | Colon missing after while. | Python |
items[16] | if (length(items) >= 16) items[16] | Check length. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
value: message
value: test, | value: message
value: test | Remove comma. | YAML |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (count = 89) {} | if (count == 89) {} | Use ==. | Dart |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:57}}; | Add missing property. | TypeScript |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if (c) console.log('yes') else console.log('no') | if (c) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (y = 93) {{}} | if (y === 93) {{}} | Use === for equality. | JavaScript |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
DELETE FROM orders WHERE id=97 | DELETE FROM orders WHERE id=97; | Add semicolon. | SQL |
if ($temp = 66) | if ($temp == 66) | Use ==. | Perl |
<br></br> | <br> | Self-closing. | HTML |
render | render() | Add parentheses. | Swift |
data.forEach(function(item) {{ console.log(item); }}) | data.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
if z = 87 then
print('data')
end | if z == 87 then
print('data')
end | Use ==. | Lua |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if val > 44
puts 'message' | if val > 44
puts 'message'
end | Add 'end'. | Ruby |
with open('log.txt') as file_handle:
data = file_handle.read() | with open('log.txt') as file_handle:
data = file_handle.read() | Correct. | Python |
def bar
puts 'output'
end | def bar
puts 'output'
end | Correct. | Ruby |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
my @arr = (31,50,94); | my @arr = (31,50,94); | Correct. | Perl |
if c = 67 {{}} | if c == 67 {{}} | Use ==. | Swift |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
[x*x for x in items if x > 50] | [x*x for x in items if x > 50] | Correct list comprehension. | Python |
let count = 76; count += 1; | let mut count = 76; count += 1; | Need mut to modify. | Rust |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<p>value <b>hello</p></b> | <p>value <b>hello</b></p> | Nest properly. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const bar; | const bar = 60; | Initialize const. | JavaScript |
if (val = 37) {{}} | if (val == 37) {{}} | Use ==. | Java |
{{"title":"message",}} | {{"title":"message"}} | Remove trailing comma. | JSON |
data[17] | if (data.indices.contains(17)) data[17] | Check index. | Kotlin |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
let foo = 81; | let foo = 81; | Correct. | JavaScript |
data(65) | if length(data) >= 65, data(65), end | Check length. | MATLAB |
val z: Int = 'result' | val z: String = 'result' | Fix type. | Kotlin |
def baz(result):
return result + 1 | def baz(result):
return result + 1 | Correct. | Python |
if result = 24 | if result == 24 | Use ==. | MATLAB |
a = 68 | a=68 | No spaces. | Shell |
if (z = 68) | if (z == 68) | Use ==. | C++ |
for val in range(69)
print(val) | for val in range(69):
print(val) | Colon after for. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
if data = 59 | if data == 59 | Use ==. | Ruby |
'52' + 26 | 52 + 26 | Avoid string coercion. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
let mut y=6; let r1=&mut y; let ref2=&mut y; | let mut y=6; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let data: number | null = null; data.toFixed(84); | let data: number | null = null; if(data!==null) data.toFixed(84); | Null check. | TypeScript |
var x int | var x int | Correct. | Go |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
SELECT age email FROM products; | SELECT age, email FROM products; | Add comma. | SQL |
println('output') | println("output") | Double quotes. | Scala |
print('info') | print('info') | Correct. | R |
<input type='text' value='test'> | <input type='text' value='test' name='value'> | Add name attribute. | HTML |
let a: number = 'message'; | let a: string = 'message'; | Fix type. | TypeScript |
re.sqrt(2) | import re
re.sqrt(2) | Import module first. | Python |
["output", 71] | ["output", 71] | Correct. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.