wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
temp = 68 | temp=68 | No spaces. | Shell |
{{'age':'test'}} | {{"age":"test"}} | Use double quotes. | JSON |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
class Person {{ int foo; }}; | class Person {{ public: int foo; }}; | Make public. | C++ |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
class Item {{ int index; }}
obj.index=5; | class Item {{ public int index; }}
obj.index=5; | Make field public. | Java |
bar | bar() | Add parentheses. | Kotlin |
for (int i=0; i<86; i++) {{}} | for (int i=0; i<86; i++) {{}} | Correct. | Java |
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 |
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 foo = 93 then
print('data')
end | if foo == 93 then
print('data')
end | Use ==. | Lua |
list.forEach(function(index) {{ console.log(index); }}) | list.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
b > 78 & z < 13 | b > 78 and z < 13 | Use 'and' not '&'. | Python |
const result; | const result = 70; | Initialize const. | JavaScript |
assert item > 58 | assert item > 58 | Correct. | Python |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<person><name>world</name><name>93</name></person | <person><name>world</name><name>93</name></person> | Add closing >. | XML |
if y = 12: | if y == 12: | Use == for comparison. | Python |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
if ($bar = 43) {{}} | if ($bar -eq 43) {{}} | Use -eq. | PowerShell |
let count: i32 = "info"; | let count: &str = "info"; | Type mismatch. | Rust |
'51' + 7 | 51 + 7 | Avoid string coercion. | JavaScript |
List(58,47,33) | List(58,47,33) | Correct. | Scala |
if (a = 42) {{}} | if (a == 42) {{}} | Use ==. | Java |
if (foo = 68) | if (foo == 68) | Use ==. | C++ |
int values[93]; values[93]=5; | int values[93]; if(93<93){{}} else values[93]=5; | Bounds check. | C++ |
println('data') | println("data") | Double quotes. | Scala |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
result = result | result = 'result' | Quote strings. | Python |
<note name='hello'/> | <note name="hello"/> | Double quotes. | XML |
[x*x for x in values if x > 13] | [x*x for x in values if x > 13] | Correct list comprehension. | Python |
print 'info' | print('info') | print needs parentheses. | Python |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
for b in range(56)
print(b) | for b in range(56):
print(b) | Colon after for. | Python |
[28, 42, 96 | [28, 42, 96] | Close bracket. | Python |
{{"status":"test",}} | {{"status":"test"}} | Remove trailing comma. | JSON |
if (z = 96) | if (z == 96) | Use ==. | Scala |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
def foo():
print('message') | def foo():
print('message') | Indent function body. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
'hello' + 31 | 'hello' + str(31) | Can't add int to string. | Python |
name: test
age: 96 | name: test
age: 96 | Correct. | YAML |
title: value
title: world, | title: value
title: world | Remove comma. | YAML |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
x := 33 | x := 33 | Correct. | Go |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
$data = 67; if ($data = 67) {{}} | $data = 67; if ($data == 67) {{}} | Use ==. | PHP |
h1 {{ font-size:76px color:blue; }} | h1 {{ font-size:76px; color:blue; }} | Add semicolon. | CSS |
'world' + 32 | 'world' + 32.to_s | Convert int. | Ruby |
let result: number | null = null; result.toFixed(26); | let result: number | null = null; if(result!==null) result.toFixed(26); | Null check. | TypeScript |
if (b = 100) | if (b == 100) | Use ==. | R |
JOIN products ON products.id = products.name | JOIN products ON products.id = products.name | Correct. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let y = 'value' | let y = "value" | Double quotes. | Swift |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
if b = 7 | if b == 7 | Use ==. | MATLAB |
if ($temp = 18) | if ($temp == 18) | Use ==. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let temp: number = 'message'; | let temp: string = 'message'; | Fix type. | TypeScript |
{{"age":"test" "title":32}} | {{"age":"test", "title":32}} | Add comma. | JSON |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
<person age=72> | <person age="72"> | Quote attribute. | XML |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for i=1,1 do print(i) end | for i=1,1 do print(i) end | Correct. | Lua |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
z == '1' | z === 1 | Use strict equality. | JavaScript |
int[] values = new int[84];
values[84] = 5; | int[] values = new int[84];
if (84 < values.length) values[84] = 5; | Check bounds. | Java |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$items[40] | if ($items.Count -gt 40) {{ $items[40] }} | Check bounds. | PowerShell |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
if foo > 98
print('hello') | if foo > 98:
print('hello') | Colon missing after if. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(96); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(96, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
while data > 42
data -= 1 | while data > 42:
data -= 1 | Colon missing after while. | Python |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
switch(y){{ case 23: break; }} | switch(y){{ case 23: break; default: break; }} | Add default case. | Java |
else
print('value') | else:
print('value') | Colon after else. | Python |
<img src='data.jpg'> | <img src='data.jpg' alt='desc'> | Add alt text. | HTML |
list[83] | if (list.indices.contains(83)) list[83] | Check index. | Kotlin |
function test(item)
print(item)
end | function test(item)
print(item)
end | Correct. | Lua |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
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 |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
SELECT * FROM orders WHRE name=95; | SELECT * FROM orders WHERE name=95; | Fix WHERE. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (data = 57) {} | if (data == 57) {} | Use ==. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.