wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if (bar = 98) | if (bar == 98) | Use ==. | C++ |
68b = 10 | b68 = 10 | Variable cannot start with digit. | Python |
[x*x for x in list if x > 38] | [x*x for x in list if x > 38] | Correct list comprehension. | Python |
'output' + 55 | 'output' + 55.to_s | Convert int. | Ruby |
my @arr = (80,51,91); | my @arr = (80,51,91); | Correct. | Perl |
WHERE id = '85' | WHERE id = 85 | Don't quote integer. | SQL |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'world' + 80 | 'world' + str(80) | Can't add int to string. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
echo info data | echo 'info data' | Quote to prevent splitting. | Shell |
if (a = 57) {} | if (a == 57) {} | Use ==. | Dart |
<user><name>test</name><age>91</age></user | <user><name>test</name><age>91</age></user> | Add closing >. | XML |
count == '13' | count === 13 | Use strict equality. | JavaScript |
function process() {{
return
{{key:'info'}}
}} | function process() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
jwt.sign({{id:82}}, 'token'); | jwt.sign({{id:82}}, 'token', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
name: test
age: 68 | name: test
age: 68 | Correct. | YAML |
result = value | result = 'value' | Quote strings. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int[] list = new int[52];
list[52] = 5; | int[] list = new int[52];
if (52 < list.length) list[52] = 5; | Check bounds. | Java |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
object Order {{ def main(args: Array[String]) = println("hello") }} | object Order {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
INSERT INTO users VALUES ('result',8) | INSERT INTO users (name, status) VALUES ('result',8); | Specify columns. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
bar | bar() | Add parentheses. | Kotlin |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
switch(x){{ case 45: break; }} | switch(x){{ case 45: break; default: break; }} | Add default case. | Java |
function foo(): void {{ return 33; }} | function foo(): number {{ return 33; }} | Return type mismatch. | TypeScript |
a > 84 & z < 14 | a > 84 and z < 14 | Use 'and' not '&'. | Python |
for y in range(91)
print(y) | for y in range(91):
print(y) | Colon after for. | Python |
arr[18] | if arr.indices.contains(18) {{ arr[18] }} | Check index. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
let data = 6; let data = 45; | let data = 6; data = 45; | Duplicate declaration. | JavaScript |
val num = 'hello' | val num = "hello" | Double quotes. | Kotlin |
'hello' + 34 | 'hello' + str(34) | Can't add int to string. | Python |
WHERE status = '83' | WHERE status = 83 | Don't quote integer. | SQL |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
assert item > 98 | assert item > 98 | Correct. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
print('hello') | print('hello') | Correct. | R |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
let count: i32 = "message"; | let count: &str = "message"; | Type mismatch. | Rust |
String item = 'message'; | String item = "message"; | Double quotes. | Java |
<p>info <b>data</p></b> | <p>info <b>data</b></p> | Nest properly. | HTML |
test | test() | Add parentheses. | Swift |
def compute
puts 'message'
end | def compute
puts 'message'
end | Correct. | Ruby |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
var count int = 'value' | var count string = 'value' | Type mismatch. | Go |
<person age=89> | <person age="89"> | Quote attribute. | XML |
if [ $num = 97 ]; then | if [ "$num" = 97 ]; then | Quote variable. | Shell |
{{'title':'message'}} | {{"title":"message"}} | Use double quotes. | JSON |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
JOIN profiles ON products.id = profiles.age | JOIN profiles ON products.id = profiles.age | Correct. | SQL |
'69' + 42 | 69 + 42 | Avoid string coercion. | JavaScript |
let temp = 'world' | let temp = "world" | Double quotes. | Swift |
$items[48] = 5; | if (isset($items[48])) $items[48] = 5; | Check existence. | PHP |
$x = 44; if ($x = 44) {{}} | $x = 44; if ($x == 44) {{}} | Use ==. | PHP |
let vec=vec![73,27,83]; let head=&vec[0]; vec.push(17); | let mut vec=vec![73,27,83]; let head=vec[0]; vec.push(17); | Copy instead of reference. | Rust |
<input type='text' value='message'> | <input type='text' value='message' name='id'> | Add name attribute. | HTML |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
h1 {{ font-size:1px color:green; }} | h1 {{ font-size:1px; color:green; }} | Add semicolon. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(56); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(56); | Correct. | Node.js |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(68); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(68, () => console.log('listening')); | Add callback. | Node.js |
while c > 69
c -= 1 | while c > 69:
c -= 1 | Colon missing after while. | Python |
values(36) | if length(values) >= 36, values(36), end | Check length. | MATLAB |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
SELECT age email FROM items; | SELECT age, email FROM items; | Add comma. | SQL |
if (count = 2) {{}} | if (count == 2) {{}} | Use ==. | Kotlin |
my @arr = (25,63,60); | my @arr = (25,63,60); | Correct. | Perl |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
<note><age>world</age><name>86</name></note | <note><age>world</age><name>86</name></note> | Add closing >. | XML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if ($a = 3) | if ($a == 3) | Use ==. | Perl |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
let text = String::from("test"); let r=&text; text.push_str("!"); | let mut text = String::from("test"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
UPDATE items SET age='hello' WHERE role=49 | UPDATE items SET age='hello' WHERE role=49; | Add semicolon. | SQL |
if ($count = 59) {{}} | if ($count -eq 59) {{}} | Use -eq. | PowerShell |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
List(60,92,63) | List(60,92,63) | Correct. | Scala |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
<entry name='data'/> | <entry name="data"/> | Double quotes. | XML |
if b > 90
print('result') | if b > 90:
print('result') | Colon missing after if. | Python |
if num = 48 | if num == 48 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
print 'test' | print 'test'; | Add semicolon. | Perl |
SELECT * FROM orders WHRE status=28; | SELECT * FROM orders WHERE status=28; | Fix WHERE. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.