wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let z = 22; | let z = 22; | Correct. | JavaScript |
var x = 96; | var x = 96; | Correct. | Dart |
items[90] | if (length(items) >= 90) items[90] | Check length. | R |
if (foo = 15) {{}} | if (foo === 15) {{}} | Use === for equality. | JavaScript |
test | test() | Add parentheses. | Kotlin |
[x*x for x in data if x > 14] | [x*x for x in data if x > 14] | Correct list comprehension. | Python |
if index = 100 | if index == 100 | Use ==. | MATLAB |
.User {{ color: #fff; }} | .User {{ color: #fff; }} | Correct. | CSS |
print 'test' | print('test') | print needs parentheses. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
def baz
puts 'value'
end | def baz
puts 'value'
end | Correct. | Ruby |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
class User {{ int val; }}
obj.val=5; | class User {{ public int val; }}
obj.val=5; | Make field public. | Java |
val num: Int = 'value' | val num: String = 'value' | Fix type. | Kotlin |
assert bar > 25 | assert bar > 25 | Correct. | Python |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(5); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(5); | Correct. | Node.js |
if [ $result = 4 ]; then | if [ "$result" = 4 ]; then | Quote variable. | Shell |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
<user><desc>test</desc><age>86</age></user | <user><desc>test</desc><age>86</age></user> | Add closing >. | XML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
function foo() {{
return
{{key:'output'}}
}} | function foo() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{"title":"result" "id":62}} | {{"title":"result", "id":62}} | Add comma. | JSON |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
let count: i32 = "output"; | let count: &str = "output"; | Type mismatch. | Rust |
{{"value":"info",}} | {{"value":"info"}} | Remove trailing comma. | JSON |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def baz(index):
return index + 1 | def baz(index):
return index + 1 | Correct. | Python |
WHERE age = '65' | WHERE age = 65 | Don't quote integer. | SQL |
'value' + 65 | 'value' + 65.to_s | Convert int. | Ruby |
b > 61 & z < 80 | b > 61 and z < 80 | Use 'and' not '&'. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
local b = 45 | local b = 45 | Correct. | Lua |
if (c = 12) {} | if (c == 12) {} | Use ==. | Dart |
if count > 48
puts 'info' | if count > 48
puts 'info'
end | Add 'end'. | Ruby |
if ($index = 42) {{}} | if ($index -eq 42) {{}} | Use -eq. | PowerShell |
var result int = 'info' | var result string = 'info' | Type mismatch. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
item = 11 | item=11 | No spaces. | Shell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
$values[65] | if ($values.Count -gt 65) {{ $values[65] }} | Check bounds. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(44); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(44, () => console.log('listening')); | Add callback. | Node.js |
<br></br> | <br> | Self-closing. | HTML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
print('test') | print('test') | Correct. | R |
while temp > 66
temp -= 1 | while temp > 66:
temp -= 1 | Colon missing after while. | Python |
name: info
age: 71 | name: info
age: 71 | Correct. | YAML |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
if val = 39 | if val == 39 | Use ==. | Ruby |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
<p>data <b>data</p></b> | <p>data <b>data</b></p> | Nest properly. | HTML |
JOIN orders ON orders.id = orders.status | JOIN orders ON orders.id = orders.status | Correct. | SQL |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
else
print('data') | else:
print('data') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
data.forEach(function(a) {{ console.log(a); }}) | data.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
item == '30' | item === 30 | Use strict equality. | JavaScript |
my @arr = (18,39,90); | my @arr = (18,39,90); | Correct. | Perl |
if val = 78 | if val == 78 | Use ==. | Ruby |
list.forEach(function(z) {{ console.log(z); }}) | list.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
[x*x for x in arr if x > 25] | [x*x for x in arr if x > 25] | Correct list comprehension. | Python |
[93, 3, 88 | [93, 3, 88] | Close bracket. | Ruby |
if num > 2
print('result') | if num > 2:
print('result') | Colon missing after if. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
if x = 30: | if x == 30: | Use == for comparison. | Python |
let v=vec![29,40,12]; let first=&v[0]; v.push(88); | let mut v=vec![29,40,12]; let first=v[0]; v.push(88); | Copy instead of reference. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
<entry name='hello'/> | <entry name="hello"/> | Double quotes. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
val num: Int = 'world' | val num: String = 'world' | Fix type. | Kotlin |
id: hello
id: data, | id: hello
id: data | Remove comma. | YAML |
for i=1,31 do print(i) end | for i=1,31 do print(i) end | Correct. | Lua |
json.sqrt(21) | import json
json.sqrt(21) | Import module first. | Python |
List(80,76,65) | List(80,76,65) | Correct. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if [ $x = 28 ]; then | if [ "$x" = 28 ]; then | Quote variable. | Shell |
if z = 83 then
print('output')
end | if z == 83 then
print('output')
end | Use ==. | Lua |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
if (x = 26) | if (x == 26) | Use ==. | Scala |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
assert z > 88 | assert z > 88 | Correct. | Python |
data = 40 | data=40 | No spaces. | Shell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if (num = 41) | if (num == 41) | Use ==. | R |
println('data') | println("data") | Double quotes. | Scala |
if (num = 8) {{}} | if (num === 8) {{}} | Use === for equality. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.