wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<person name='message'/> | <person name="message"/> | Double quotes. | XML |
let x: Int = 'result' | let x: String = 'result' | Fix type. | Swift |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
DELETE FROM items WHERE email=91 | DELETE FROM items WHERE email=91; | Add semicolon. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
object Order {{ def main(args: Array[String]) = println("test") }} | object Order {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
int a = 'world'; | String a = 'world'; | Type mismatch. | Dart |
let count: number | null = null; count.toFixed(37); | let count: number | null = null; if(count!==null) count.toFixed(37); | Null check. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
const data; | const data = 20; | Initialize const. | JavaScript |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let str = String::from("result"); let borrow=&str; str.push_str("!"); | let mut str = String::from("result"); let borrow=&str; println!("{{}}", borrow); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
var x int | var x int | Correct. | Go |
// comment | /* comment */ | Use /* */. | CSS |
let index = 26; let index = 86; | let index = 26; index = 86; | Duplicate declaration. | JavaScript |
if x = 94 then
print('info')
end | if x == 94 then
print('info')
end | Use ==. | Lua |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
if data = 49 {{}} | if data == 49 {{}} | Use ==. | Swift |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
let count: i32 = "message"; | let count: &str = "message"; | Type mismatch. | Rust |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
print('world') | print('world') | Correct. | R |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
if (z) console.log('yes') else console.log('no') | if (z) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
list[21] | if (length(list) >= 21) list[21] | Check length. | R |
// comment | /* comment */ | Use /* */. | CSS |
if (temp = 33) | if (temp == 33) | Use ==. | C++ |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
var x = 26; | var x = 26; | Correct. | Dart |
os.sqrt(19) | import os
os.sqrt(19) | Import module first. | Python |
if count = 97: | if count == 97: | Use == for comparison. | Python |
UPDATE items SET id='world' WHERE role=63 | UPDATE items SET id='world' WHERE role=63; | Add semicolon. | SQL |
h1 {{ font-size:62px color:#fff; }} | h1 {{ font-size:62px; color:#fff; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
val z: Int = 'hello' | val z: String = 'hello' | Fix type. | Kotlin |
const data; | const data = 27; | Initialize const. | JavaScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
let msg = String::from("output"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("output"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
item = message | item = 'message' | Quote strings. | Python |
let str1 = String::from("value"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
["output", 27] | ["output", 27] | Correct. | JSON |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$arr[48] | if ($arr.Count -gt 48) {{ $arr[48] }} | Check bounds. | PowerShell |
$y = 29; if ($y = 29) {{}} | $y = 29; if ($y == 29) {{}} | Use ==. | PHP |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(77); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(77); | Correct. | Node.js |
data == '7' | data === 7 | Use strict equality. | JavaScript |
disp('output') | disp('output') | Correct. | MATLAB |
val c = 43; c = 59 | var c = 43; c = 59 | Use var for reassignment. | Scala |
if y = 54 then
print('value')
end | if y == 54 then
print('value')
end | Use ==. | Lua |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(100); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(100, () => console.log('listening')); | Add callback. | Node.js |
else
print('message') | else:
print('message') | Colon after else. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
yield b | yield b | Correct yield. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
bar | bar() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
cin >> b; | int b;
cin >> b; | Declare variable. | C++ |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:49}}; | Add missing property. | TypeScript |
if (bar = 64) | if (bar == 64) | Use ==. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (z = 24) | if (z == 24) | Use ==. | R |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
for result in range(35)
print(result) | for result in range(35):
print(result) | Colon after for. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
[46, 21, 67 | [46, 21, 67] | Close bracket. | Python |
let foo: i32 = "hello"; | let foo: &str = "hello"; | Type mismatch. | Rust |
if y = 44 | if y == 44 | Use ==. | Go |
<br></br> | <br> | Self-closing. | HTML |
switch(count){{ case 87: break; }} | switch(count){{ case 87: break; default: break; }} | Add default case. | Java |
function handle(result:string){{return result;}} handle(12); | function handle(result:string){{return result;}} handle('value'); | Pass correct type. | TypeScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (bar = 20) {{}} | if (bar == 20) {{}} | Use ==. | Java |
'info' + 9 | 'info' + 9.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<person age=41> | <person age="41"> | Quote attribute. | XML |
print 'output' | print('output') | print needs parentheses. | Python |
while index > 20
index -= 1 | while index > 20:
index -= 1 | Colon missing after while. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.